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.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version