I am new to C# programming, and I recently got this form application project from my coworker. Inside FormClosed event method, I see two lines of code:
Environment.Exit(0);
Application.Exit();
Then I looked them up to see the difference, and I read many SO posts about this. Many say if you are using
Application.Run();
method to start the form application, use
Application.Exit();
However, many also say just using
Environment.Exit(0);
is enough too. So after all, which needs to be used? The more I read, the more I get confused and at a loss which to use. I also noticed that if I put breakpoints on both lines, when the program comes to the line:
Environment.Exit(0);
the form closes and goes back to the coding screen. So I switched the order so both of them will be executed, but is it even correct to run both of them upon closing the application?