© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
17 replies
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");

im in a infinite loop and not sure how to get out. tldr im very new as im still trying to learn
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Need help for loop
C#CC# / help
4y ago
✅ hey I need some help!
C#CC# / help
17mo ago
❔ Need some help.
C#CC# / help
3y ago
Need some help
C#CC# / help
4y ago