- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Exit Methods in C# Application
Environment.Exit() method
The 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 show an error, for example −
Environment.Exit(1) − Return a value 1 to show that the file you want is not present
Environment.Exit(2) − Return a value 2 to indicate that the file is in an incorrect format.
System.Windows.Forms.Application.ExitThread( )
To close a subapplication or current thread in a Windows Form, use theSystem.Windows.Forms.Application.ExitThread( ).
private void buttonClose_Click(object sender, EventArgs eventArgs) { System.Windows.Forms.Application.ExitThread( ); }
Advertisements