Command to Close an Application of Console

Command to close an application of console?

Environment.Exit and Application.Exit

Environment.Exit(0) is cleaner.

http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx

What is the command to exit a console application in C#?

You can use Environment.Exit(0); and Application.Exit

Environment.Exit(0) is cleaner.

To exit the console window in a C# console application

Environment.Exit and Application.Exit

Environment.Exit(0) is cleaner.

How to stop C# console applications from closing automatically?

Update:

As of Visual Studio 2017, there's a built-in option in the IDE at:

Tools > Options > Debugging > Automatically close the console when debugging stops

Unchecking it will automatically pause the application at the end of the execution, allowing you the easily check its output without having to add extra code to your application.


There are two ways;

Console.ReadLine();

ReadLine() waits for

or

Console.ReadKey();

ReadKey() waits for any key (except for modifier keys).



Related Topics



Leave a reply



Submit