C# Environment Exit
Description
Environment Exit
terminates this process and gives the
underlying operating system the specified exit code.
Syntax
Environment.Exit
has the following syntax.
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public static void Exit(
int exitCode
)
Parameters
Environment.Exit
has the following parameters.
exitCode
- Exit code to be given to the operating system. Use 0 (zero) to indicate that the process completed successfully.
Returns
Environment.Exit
method returns
Example
Terminates this process and gives the underlying operating system the specified exit code.
using System;/*from w ww.ja v a 2s . co m*/
class Sample
{
public static void Main()
{
Environment.Exit(0);
}
}
The code above generates the following result.