
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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( ); }
- Related Articles
- How to exit iPhone application gracefully?
- Management Training Methods: Meaning & Application
- Application of Sampling Distribution Methods in Psychology
- Difference Between exit(0) and exit(1)
- exit() function in PHP
- exit() vs _Exit() in C/C++
- Node.js – process ‘exit’ Event
- exit(), abort() and assert() in C/C++
- return statement vs exit() in main() C++
- Disable Exit (or [ X ]) in Tkinter Window
- What is exit() function in C language?
- How to exit a process in Node.js?
- Python Program Exit handlers (atexit)
- exit() vs _Exit() function in C and C++
- Return Statement vs Exit() in Main() using C++

Advertisements