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
Choose One of Many Internet Connections for an Application
How to Name Variables Dynamically in C#
Parse Datetime in Multiple Formats
How to Handle Null or Optional Dll Struct Parameters
What Is the Maximum Resolution of C# .Net Bitmap
Equivalent of SQL Isnull in Linq
Modify Struct Variable in a Dictionary
How to Bind Parameters via Odbc C#
Sqlconnection SQLcommand SQLdatareader Idisposable
Capture Multiple Key Downs in C#
What's the Best Strategy for Equals and Gethashcode
How to Save Image in Database Using C#
No Console Output When Using Allocconsole and Target Architecture X86
What Happens If I Don't Call Dispose on the Pen Object
Why Explicit Implementation of a Interface Can Not Be Public