Do you quite often find yourself putting Console.ReadLine() at the end of each of your console programs so you can see the output before Visual Studio closes the window? And then you find yourself in the embarrasing situation of leaving the code in when it’s deployed so that whenever you run the application from the command line, it ends up sitting there waiting for you to press a key? Well, next time, wrap it in the following:

if (System.Diagnostics.Debugger.IsAttached)
Console.WriteLine("Press a key to quit...");

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s