I'm new to C# and am making a text based game. Upon finishing it up, I've learned that gotos are the spawn of Satan (pffft). I have a lot of instances in this script where I ask the player a yes or no question, and if the player inputs anything else, they get an error message and I loop back to the start of the switch using a goto and a label. So given the example below, what would be a way to rework this code to produce the same results without using a goto? Thank you!
public static void One()
{
string response;
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Clear();
Console.WriteLine("Some text.");
OneOne:
Console.ReadKey();
Console.Write("\nA question?");
response = Console.ReadLine().ToLower();
Console.Clear();
switch (YesOrNoDetector.Detect(response))
{
case YesOrNo.Yes:
{
Console.WriteLine("A response!");
Console.ReadKey();
Two();
break;
}
case YesOrNo.No:
{
Console.WriteLine("A different response.");
Console.ReadKey();
Three();
break;
}
case YesOrNo.Undefined:
{
Console.WriteLine("Refresh switch to look for a yes/no answer");
goto OneOne;
}
}
}