I am currently looking for a solution for this c# console application function
I tried searching for a method for creating a while loop that can terminate for the co
I hope this is what you need. The possibles values are in the List "list" and it loops until the answer is one of the possible values:
int value = 0;
List list = new List { 1, 2, 3, 4 }; // choices are in the list
while (true)
{
Console.WriteLine("Please enter a number :");
if (int.TryParse(Console.ReadLine(), out value))
{
if (list.Contains(value))
break;
}
}
// value is in the list, deal with it.