Environment.Exit() method terminates the process and returns an exit code to the operating system -
Environment.Exit(exitCode);
Use exitCode as 0 (zero) to show that the process completed successfully.
Use exitCode as a non-zero number to display errors, for example -
Environment.Exit(1)- a return value of 1 means you want The file does not exist
Environment.Exit(2)- A return value of 2 indicates that the file format is incorrect.
To close a child application or the current thread in Windows Forms, use System.Windows.Forms .Application.ExitThread( ).
private void buttonClose_Click(object sender, EventArgs eventArgs) { System.Windows.Forms.Application.ExitThread( ); }
The above is the detailed content of Exit method in C# application. For more information, please follow other related articles on the PHP Chinese website!