Pause Output From a Command Line Application in .NET Debug Mode

If you are writing a command line application in .NET, you might notice that the application closes immediately if you haven’t set a breakpoint. This recipe shows you the one line method to keep the application open so you can see the output.


Typically when you are writing to the console, you use the Console.Write() method, but there is also a Read method to go along with it.

If you place this line of code in your application, it will pause and wait for a keystroke before continuing:
Console.ReadLine();

If you are using Visual Basic instead of C#, just omit the semicolon.

The Conversation

Follow the reactions below and share your own thoughts.

Leave a Reply