Better to add to your toolbox of utility/helper methods:
static bool WaitForKeyPress()
{
return WaitForKeyPress( ConsoleKey.Escape ) ;
}
static bool WaitForKeyPress( ConsoleKey quit_key )
{
ConsoleKeyInfo keypress ;
bool fQuit = false ;
FlushConsoleInputBuffer() ;
WriteConditionalEOL() ;
Console.Write( "Press ESC to quit or any other key to continue> " ) ;
keypress = Console.ReadKey( false );
fQuit = ( keypress.Key == quit_key ? true : false );
WriteConditionalEOL();
return fQuit;
}
private static void FlushConsoleInputBuffer()
{
while ( Console.KeyAvailable )
{
Console.ReadKey( true ); // true: don't echo input
}
return;
}
private static void WriteConditionalEOL()
{
if ( Console.CursorLeft > 0 )
{
Console.WriteLine();
}
return;
}