The user Input should be within 0 to 10 and I want to use tryparse and check if the input is correct, if not then it should prompt the user again. my code is like below it only works once but if the user enters the wrong number it again executes. In this case, where should I put the loop?
int number;
bool True;
Console.Write("Enter number between 0 t0 10: ");
True = int.TryParse(Console.ReadLine(), out number);
while (number < 0 || number > 10)
{
while (True)
Console.Write("Enter number between 0 t0 10: ");
int.TryParse(Console.ReadLine(), out number);
}
{
Console.WriteLine("Please enter the correct number");
}
return number;
TryParse- in case they type inBob.