recursion - C# recalling method leads to program exit -


i've been coding text adventure game. when program run, boot() method called, reading %appdata%.ilan\texert setting files (meanwhile there username.txt). after boot(), goes mainmenu(), user can choose play, go options, or exit. when user goes options menu, , comes back, tries play game or return options menu, game quits, not supposed happen. source
boot() = line 455
mainmenu() = line 579
main() = line 504
believe because int declared in method itself, , because method called multiple times int variable retains previous value. there way fix this?

at line 610 retrieve results of mainmenu method, call optionmenu method @ line 617, once optionmenu() method fires don't else prevent application ending once control returns main() method. though call mainmenu() in optionmenu() method there nothing evaluating results of call write menu console , return main(). need put loop in main() method repeatedly call mainmenu() method, evaluating selected results, , other menu options optionmenu() return loop rather calling main menu themselves. this:

string whattodo = "null"; bool exitapp = false; while (!exitapp) {     whattodo = advtime.mainmenu();     if (whattodo.contains("play"))     {         menu("null", false);     }     if (whattodo.contains("options"))     {         advtime.optionmenu();     }     if (whattodo.contains("exit"))     {         exitapp = true;     }     if (whattodo.contains("null"))     {         advtime.mmerror("om");     } } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -