It doesn't appear that you understand what the real difference between the Show and ShowDialog methods or how the program actually runs.
When your C# program starts, the first thing the application does is to create a new form of whichever form is your main form and then run it. The application will quit when that form is closed. From MSDN: "This method adds an event handler to the mainForm parameter for the Closed event. The event handler calls ExitThread to clean up the application."
This means that whenever your main form is closed, the application will close unless your Program.cs has anything after that call.
As to the difference between Show and ShowDialog, ShowDialog does the same basic thing. When that line of code runs, it will wait until that form has closed to run the next line of code. So with your code,
Form2 nextForm = new Form2();
this.Hide();
nextForm.ShowDialog();
this.Close();
this.Close();
will not be hit until
nextForm
is closed.
SeniorCrispy wrote:
all the previous forms will still be in memory and have some kind of performance impact.
That's true. If you don't close a form, it will still be in memory. However, you have to keep your main form open or the application will close. But, honestly, keeping the main form open is really a pretty insignificant use of memory.