I want to ask the user to input a number including an if statement option were if he puts letters the last question will be asked again I've tried this but seemingly it work only for strings
Console.Write("Write a number:");
int num = Convert.ToInt32(Console.ReadLine());
if (!int.TryParse(age, out num))
while(!int.TryParse(age, out num))
{
Console.WriteLine(...);
// ....
}
Aucun commentaire:
Enregistrer un commentaire