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...");
Console.ReadKey(true);
}