How to return to menu with switch case statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to return to menu with switch case statement?

I am trying to find a way how to return case 3 back to the top of the code to output the same thing again after the user enter case 3. How do I do this? https://code.sololearn.com/csETbpgnARgZ/?ref=app

17th Oct 2022, 9:17 PM
Liam
2 Answers
+ 1
The only way to so this is on a loop and switch doesn't do that, my advice is to change it to a while loop. But if you reeeaaally want to use a switch case you can do something a little bit silly: recursion with Main. It would be something like this: case 3: Console.WriteLine("Coming soon!"); Main(new String[0]); break; I'm not sure if I helped but Keep the good coding :)
17th Oct 2022, 9:24 PM
Tomás Ribeiro
Tomás Ribeiro - avatar
0
Great! Thanks for your help 👍🏼
17th Oct 2022, 9:38 PM
Liam