Export (0) Print
Expand All

Environment.ExitCode Property

Gets or sets the exit code of the process.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static int ExitCode { get; set; }
/** @property */
public static int get_ExitCode ()

/** @property */
public static void set_ExitCode (int value)

public static function get ExitCode () : int

public static function set ExitCode (value : int)

Property Value

A 32-bit signed integer containing the exit code. The default value is zero.

This property can be used to return a success code from an application. For example, it can be used to control the execution of a set of applications invoked in a script. If the value of this property is not set by an application, zero is returned.

The system exit code is set to the return value of the function, main, or zero if main returns void, regardless of whether the user sets this property.

The following code example displays its own exit code.

// Sample for the Environment.ExitCode property
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine();
    Console.WriteLine("ExitCode: {0}", Environment.ExitCode);
    }
}
/*
This example produces the following results:

ExitCode: 0
*/

// Sample for the Environment.ExitCode property
import System.*;

class Sample
{
    public static void main(String[] args)
    {
        Console.WriteLine();
        Console.WriteLine("ExitCode: {0}", 
            System.Convert.ToString(Environment.get_ExitCode()));
    } //main
} //Sample

/*
This example produces the following results:

ExitCode: 0
*/

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft