PROPERTY

Environment.ExitCode

Sets or reads the process exit code for programs that use the property. A returned int from Main or top-level statements takes precedence over this property. Exit status is separate from printed text.

Formal Syntax & Structure

csharp syntaxcsharp
Environment.ExitCode = code;

Working Example

Example Snippetcsharp
using System;Console.WriteLine("Completed"); Environment.ExitCode = 0;
C# & .NET Reference