I want to keep reading lines of the user, but when this user presses on escape I want it to stop. But how can I keep reading single keys (for the escape), while meanwhile reading lines? I hope the question will be more clear after giving my code:
int number;
do
{
string a = Console.ReadLine();
try
{
Int32.TryParse(a, out number);
}
catch
{
Console.WriteLine("I only accept int");
}
finally
{
Console.Writeline(number);
}
} while (Console.ReadKey(true).Key != ConsoleKey.Escape);