How do you display an error message written like this: (“101 is not a valid mark, enter a number between 0 and 100”) in this code?
using System;
class Program {
public static bool isVaild(int num)
{
if(num>=0&&num<100)
{
return true;
}
return false;
}
public static void Main (string[] args) {
int num=Convert.ToInt32(Console.ReadLine());
while(!isVaild(num))
{
Console.WriteLine($"{num} is not a valid mark, enter a number between 0 and 100");
num=Convert.ToInt32(Console.ReadLine());
}
Console.ReadKey();
}
}
Comments
Leave a comment