Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace WhileLoops
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool displayMenu = true;
- while (displayMenu)
- {
- displayMenu = MainMenu();
- }
- }
- private static bool MainMenu()
- {
- Console.WriteLine("Choose an option: ");
- Console.WriteLine("1) Option 1 ");
- Console.WriteLine("2) Option 2 ");
- Console.WriteLine("3) Exit");
- string result = Console.ReadLine();
- if (result == "1")
- {
- Option1();
- return true;
- }
- else if (result == "2")
- {
- Option2();
- return true;
- }
- else if (result == "3")
- {
- Exit();
- return false;
- }
- else
- {
- InvalidInput();
- return true;
- }
- }
- private static void Option1()
- {
- Console.WriteLine("Option 1 sub-menu");
- Console.ReadLine();
- }
- private static void Option2()
- {
- Console.WriteLine("Option 2 sub-menu");
- Console.ReadLine();
- }
- private static void Exit()
- {
- }
- private static void InvalidInput()
- {
- Console.WriteLine("Sorry, we do not understand");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement