ari ishtar
ari ishtar
CC#
Created by ari ishtar on 9/26/2023 in #help
❔ 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");
im in a infinite loop and not sure how to get out. tldr im very new as im still trying to learn
18 replies