Closing the console window during debugging

When I run the program without debugging (Ctrl + F5), I have to press a key to close the console window when the program is finished. When I run the debugging program (F5), the console window closes immediately. Is there an option in Visual Studio that will keep the window open when debugging?

(I know a thousand ways to do this “manually” in code, but I don't want to touch the code.)

+7
source share
3 answers

Add a breakpoint to the end bracket of the main() method. Thus, if the program terminates (if it does not end in the process, which in any case will cause a break), it will break regardless of which return statement was used in main .

+6
source

I don’t think so, but you could do it manually

  • add a breakpoint at the end of the main method
  • add a read function at the end of the main function so that it remains open for reading input and closing if you press any key
+1
source

yes, if you open your properties for the current project, not a solution,

And install it in the console application from the Windows Forms application, and it will open for you and will only close when you close the application or close the application if you close the console.

and if you are writing a console application, just put readLn (); at the end of main () is not a breakpoint, as this will stop your application from responding

0
source

All Articles