c# press enter to continue code example
Example: c# enter key press console
// ---------- How to detect when the input is ENTER? ----------- //
string input = "";
// 1º Method
while(true)
{
Console.WriteLine("Write something (or hit ENTER to quit): ");
input = Console.ReadLine();
if( string.IsNullOrWhiteSpace(input)) )
break;
else
// some code...
}
// 2º Method
while(true)
{
Console.WriteLine("Write something (or hit ENTER to quit): ");
input = Console.ReadLine();
if( input.Equals("") )
break;
else
// some code...
}