I have a console app with an int
variable. I need to read input from the user and be sure I can tell the user that they have entered an invalid answer if the input can't convert to an integer value.
How can I do this? Here is what I have so far:
class Program
{
static void Main(string[] args)
{
Start:
Console.WriteLine("Enter two numbers");
var input1 = Convert.ToInt32(Console.ReadLine());
var input2 = Convert.ToInt32(Console.ReadLine());
if (input1 + input2 == 3)
Console.WriteLine("");
else if (input1 + input2 == 10)
{
Console.WriteLine("");
}
else
Console.WriteLine("");
goto Start;
}
}