ari ishtar
❔ i need some help getting out of loop
do
{
try
{
Console.WriteLine();
Console.WriteLine("please enter one of the names shown above. (correct spelling)");
gasName = Console.ReadLine();
}
catch (System.FormatException ex)
{
Console.WriteLine("not a gas == " + ex.Message);
good = false;
}
catch (System.OverflowException ex)
{
Console.WriteLine("not the right name == " + ex.Message);
}
catch (Exception ex)
{
Console.WriteLine("error data == " + ex.Data + " == " + ex.Message);
}
finally
{
Console.WriteLine("will you like to try again? ");
if (good)
{
doAgain = "no";
}
else
{
doAgain = "yes";
}
}
} while (doAgain == "no");
do
{
try
{
Console.WriteLine();
Console.WriteLine("please enter one of the names shown above. (correct spelling)");
gasName = Console.ReadLine();
}
catch (System.FormatException ex)
{
Console.WriteLine("not a gas == " + ex.Message);
good = false;
}
catch (System.OverflowException ex)
{
Console.WriteLine("not the right name == " + ex.Message);
}
catch (Exception ex)
{
Console.WriteLine("error data == " + ex.Data + " == " + ex.Message);
}
finally
{
Console.WriteLine("will you like to try again? ");
if (good)
{
doAgain = "no";
}
else
{
doAgain = "yes";
}
}
} while (doAgain == "no");
18 replies