Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1076881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:29:41+00:00 2026-05-16T21:29:41+00:00

I am new to C#. I have a menu in a console app. Now

  • 0

I am new to C#. I have a “menu” in a console app. Now when I have finished picking an item out of the menu and doing what that menu item require I want to loop and show the menu again so that the user can choose a diffenrent menu item. I have an exit on the menu and I only want to use that to exit. I have tried a while loop but this doesnt work. It closes the app after a menu item has been chosen and the chosen items code has run. What am I doing wrong?

static void Main()
    {   
        int input = 0;
        while (true)
        {

            Console.WriteLine("MENU");
            Console.WriteLine("Please enter the number that you want to do:");
            Console.WriteLine("1. Do thing A");
            Console.WriteLine("2. Do thing B");
            Console.WriteLine("3. Do thing C");
            Console.WriteLine("4. Do thing D");
            Console.WriteLine("5. Do thing E");
            Console.WriteLine("6. Do thing F");
            Console.WriteLine("7. Exit");

            int menuchoice = int.Parse(Console.ReadLine());

            switch (menuchoice)
            {
                case 1:
                    Console.WriteLine("Thing A has been done"); 
                    break;
                case 2:
                    Console.WriteLine("Thing B has been done");
                    break;
                case 3:
                    Console.WriteLine("Thing C has been done");
                    break;
                case 4:
                    Console.WriteLine("Thing D has been done");
                    break;
                case 5:
                    Console.WriteLine("Thing E has been done");
                    break;
                case 6:
                    Console.WriteLine("Thing F has been done");
                    break;
                case 7:
                    Environment.Exit; //edit
                    break;
                default:
                    Console.WriteLine("Sorry, invalid selection");
                    break;
            }

            input++;
            if (input < 30)
                continue;
            else
                break;
        }           
    }

Can anyone please help? Thanks in advance!

EDIT: I am aware that that “Console.Exit” would not work. I did just put it like that to illastrate that the console must exit there. My problem is that I need to loop the whole menu every time after a option have been chosen and the chosen option code has run. I only want to use the exit to exit. But at this point the menu does not loop, the console closes after just 1 option have been chosen and that options code has run.

EDIT: What happens when you start your program and you press 1 followed by Return? This is the real problem, the menu doesnt seem to be looping. After I start my program and press 1 followed by return the code in case 1 runs perfectly but then the console just closes. If I start the console again and press 2 this time the code in case 2 also runs perfectly but then the console closes again. I have tested all my cases like this and all of them runs perfectly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:29:42+00:00Added an answer on May 16, 2026 at 9:29 pm

    Keep it simple: the loop stays in the loop until 7 is pressed

      int menuchoice  = 0;  
            while (menuchoice != 7)  
            {  
    
                Console.WriteLine("MENU");  
                Console.WriteLine("Please enter the number that you want to do:");  
                Console.WriteLine("1. Do thing A");  
                Console.WriteLine("2. Do thing B");  
                Console.WriteLine("3. Do thing C");  
                Console.WriteLine("4. Do thing D");  
                Console.WriteLine("5. Do thing E");  
                Console.WriteLine("6. Do thing F");  
                Console.WriteLine("7. Exit");  
    
                menuchoice = int.Parse(Console.ReadLine());  
    
                switch (menuchoice)  
                {  
                    case 1:  
                        Console.WriteLine("Thing A has been done");   
                        break;  
                    case 2:  
                        Console.WriteLine("Thing B has been done");  
                        break;  
                    case 3:  
                        Console.WriteLine("Thing C has been done");  
                        break;  
                    case 4:  
                        Console.WriteLine("Thing D has been done");  
                        break;  
                    case 5:  
                        Console.WriteLine("Thing E has been done");  
                        break;  
                    case 6:  
                        Console.WriteLine("Thing F has been done");  
                        break;  
                    case 7:  
                        break;  //edit
                    default:  
                        Console.WriteLine("Sorry, invalid selection");  
                        break;  
                }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rally.sdk.ui.basic.Dropdown menu in a Rally App that I would like to
I have a nested menu like this: <ul id=menu> <li>Home <ul> <li>New</li> <li class=selected>Open</li>
i have new webcam. The software of the webcam can give out the webcam
When we have new in C#, that personally I see only as a workaround
I made a similar question a few days ago, but now I have new
I have a Menu and Submenu structure in Silverlight, and I want the submenu
I have a menu with a 'Windows' list that contains all mdi children thanks
I currently have a menu with subitems that is being stored in this dictionary
I am trying to make a basic java console based menu system. I have
I have several menu items like this: <navigation:RadMenuItem Header=New Assignment> <navigation:RadMenuItem.Icon> <Image Source=/Images/New_Assignment.jpeg Width=20

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.