Is there a way to combine the try and catch method with the the while function whilst using the RANDOM function.
For Example:
Console.WriteLine(guess a number);
int b=Convert.ToInt32( Console.ReadLine());
Random rnd = new Random();
rnd.Next(1, 100);
int a=0;
while (a<15)
{
try
{
Console.WriteLine`("invalid input outside the ranges:");
}
catch
{
Console.WriteLine("please write only whole numbers");
}
a++
}
Thank you
Aucun commentaire:
Enregistrer un commentaire