Saturday, June 26, 2010

Do Not Exit Console Applications Automatically

If you start a console application in the .Net environment with the usual command Debug - Start Debugging (F5), the console application will end automatically after running. Often this is annoying, as you mostly miss the output then on the screen, the windows just flashes up briefly.
But if you start the application with Ctrl + F5 (Start without Debugging), the message Press any key ... is shown, the application stays open until you do so.
Alternatively, you can also append a Console.ReadKey(); in the end, now the program also waits for a user input before closing.

No comments:

Post a Comment