Environment.Exit Method
Terminates this process and gives the underlying operating system the specified exit code.
Assembly: mscorlib (in mscorlib.dll)
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] public static void Exit( int exitCode )
Parameters
- exitCode
- Type: System.Int32
Exit code to be given to the operating system. Use 0 (zero) to indicate that the process completed successfully.
| Exception | Condition |
|---|---|
| SecurityException | The caller does not have sufficient security permission to perform this function. |
Use a non-zero number to indicate an error. In your application, you can define your own error codes in an enumeration, and return the appropriate error code based on the scenario. For example, return a value of 1 to indicate that the required file is not present and a value of 2 to indicate that the file is in the wrong format. For a list of exit codes used by the Windows operating system, see System Error Codes in the Windows documentation.
- SecurityPermission
for the ability to call unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.