콘솔에서 프로그램을 종료하고자 할때 이용하세요.
Environment.Exit(0);
윈폼에서는 Application.Exit(); 입니다^^
* 아래는 Environment.Exit(0) 사용예제
// Example for the Environment.Exit( int ) method.
using System;
class ExitTest
{
public static void Main( )
{
Console.WriteLine(
"If this program is invoked with [{0}] " +
"from the command prompt,",
Environment.CommandLine );
String[ ] args = Environment.GetCommandLineArgs( );
// args[0] is the program name and, args[1] is the first argument.
// Test for a command-line argument.
if( args.Length > 1 )
{
// Parse the argument. If successful, exit with the parsed code.
try
{
int exitCode = int.Parse( args[1] );
Console.WriteLine( "it exits with code: 0x{0:X8}.", exitCode );
Environment.Exit( exitCode );
}
// If the parse fails, you fall out of the program.
catch
{ }
}
Console.WriteLine( "it exits by falling through." );
}
}
/*
If this program is invoked with [EnvExit -2147480000] from the command prompt,
it exits with code: 0x80000E40.
*/
SSISO Community