Sorry if this is similar to an existing question - I did try looking!
Anyhow, I've got a program going as follows:
static void Main(string[] args)
{
string temp;
Console.WriteLine("question");
temp = Console.ReadLine();
if (temp == "a")
{
Console.WriteLine("Incorrect");
}
if (temp == "b")
{
Console.WriteLine("Incorrect");
}
if (temp == "c")
{
Console.WriteLine("Correct");
}
else
{
Console.WriteLine("Not a valid response");
}
}
And I'm trying to get it to ignore invalid responses until I give a valid response. If for example, I needed to press the key a
, or b
, or c
but I pressed d
, it would just tell me my answer isn't a valid option and wait until I gave a valid response.