C# Console.Readkey - wait for specific input
KeyChar
is a char
while "Y"
is a string
.
You want something like KeyChar == 'Y'
instead.
Check this instead
string result = Console.ReadLine();
And after check the result
What your looking for is something like this
void PlayAgain()
{
Console.WriteLine("Would you like to play again? Y/N: ");
string result = Console.ReadLine();
if (result.Equals("y", StringComparison.OrdinalIgnoreCase) || result.Equals("yes", StringComparison.OrdinalIgnoreCase))
{
Start();
}
else
{
Console.WriteLine("Thank you for playing.");
Console.ReadKey();
}
}