So I wrote this code in my main menu
class and it worked fine:
Public Zero Start () // Start method {bool done = false; While (done!) {ShowMeny (); SwitchMethod (); NumChoice = Input Helper.ReadIntegerConsole (); If (number selection == 0) // If the input is 0, then the value is set to true and the loop is closed = true; // ...
However, here I wrote it in another class, and when you press 0, it should return to my main menu
. Why can not I use the same type of code? This is looping all the ShowMenu
.
Private Zero CalcMenu () {bool done = false; While (done!) {ShowMenu (); If (MenuChoice == 0) concludes = true; }}
If you press 0 here, it repeats it again twice. Here's the whole class:
Namespace Console Application 1 {Working Word Working {int MenuChoice = -1; Public Zero Starter () {ShowMenu (); CalcMenu (); // LoopOneWeeks (); // LoopTwoNights // ShowResults (); } Private Zero ShowMenu () {Console.WriteLine ("Slots Schema from Du Dublur:"); Console.WriteLine ("_______________________________"); Console.light line ("1. List of visas your work list"); Console.Published Line ("2. List of Visas List of Your Name"); Console.light line ("0.HVA before"); MenuChoice = Input Helper.ReadIntegerConsole (); Console.light line ("data val:" + menu option); } Private Zero CalcMenu () {bool full = false; While (done!) {ShowMenu (); If (MenuChoice == 0) {rich = true; ReturnMainMenu (); } Else if (MenuChoice == 1) {} else if (MenuChoice == 2) {}}} Private Zero returnmanain () {menu program MPObj = new menu program (); MPObj.Start (); }
InputHelper.ReadIntegerConsole is an input assistant class
When you keep your MenuChoice == 0
branch then you are not actually leaving your loop.
Private Zero CalcMenu () {bool Done = false; While (done!) {ShowMenu (); If (MenuChoice == 0) {rich = true; // ReturnMainMenu (); } And if (MenuChoice == 1) {} else if (MenuChoice == 2) {}} ReturnMainMenu (); // It just happens when you exit the loop}
Edit:
It seems that before you show the menu again in Calkman Showing the menu in Start ()
Public Zero Starter () {// ShowMenu (); CalcMenu (); // LoopOneWeeks (); // LoopTwoNights // ShowResults (); }
Comments
Post a Comment