How to stop C# console applications from closing automatically? [duplicate]

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).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)