I’ve read a lot of post (maybe not enough) in which users say to add a
console.readline()
or in C++
system("pause");
or similar hint to prevent the console closing after an exception thrown by the application. Someone talk about a breakpoint in the last code line of the application.
There’s some project property settings in VS 2010 to disable this thing?
I am a bit confused by statement that exception closes the console window. It doesn’t. Instead when you press F5 from visual studio in a Console Application and an exception occurs then it takes you to the line of code in visual studio where exception has happened. It doesn’t close the console window.
Also if you want to pause the Console window at the end of execution so that you can see the results (if you are displaying anything) then use
Console.ReadKey();at the end of the program. e.g.In this program it will display the messages and then will wait for the user to press any key. This will enable you to see the output before the console gets closed. I don’t know about any setting in visual studio which could prevent the window from closing.
(You could use ReadKey or ReadLine which are basically used to get input from console)