I have 2 try and catch but after the first catch
do
{
Console.Write("x = ");
string str = Console.ReadLine();
if (str.ToLower().Equals("exit"))
{
Console.WriteLine("Program has stopped");
break;
}
else
{
try
{
x = Convert.ToInt32(str);
Console.Write("y = ");
y = Convert.ToInt32(Console.ReadLine());
}
catch (FormatException)
{
Console.WriteLine("Input Int or type 'exit' to stop program");
}
}
if it catches then it moves on to the rest of the code. how do I return to Input another value again after catch
try
{
Console.WriteLine("Do you want to Add, Subtract, Multiply, or Divide ?");
f = Console.ReadLine();
}
catch (ArgumentException)
{
Console.WriteLine("Cannot read string");
}
if (f.ToLower().Equals("add"))
{
sum = x + y;
Console.WriteLine("Result: {0}", sum);
while (true);