Console just exiting straight after Starting?

I am really new at this, but I have made a pretty simple code using the things I have learned so far, but when I go to compile the code it just exits straight away. I have tried using Console.ReadLine(); all over and nothing changes it. Its abit long but I will post it here:

public bool WelcomeMenu() { bool carryOn = true; Console.Clear(); Console.WriteLine("Select Below"); Console.WriteLine("1) 13.00 - North"); Console.WriteLine("2) 14.00 - South"); Console.WriteLine("3) 15.00 - East"); Console.WriteLine("4) 16.00 - West"); Console.WriteLine("5) Save and exit"); Console.ReadLine(); bool validInput = false; do { validInput = true; ConsoleKeyInfo key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: SeatSelection(); break; case ConsoleKey.D2: case ConsoleKey.NumPad2: SeatSelection(); break; case ConsoleKey.D3: case ConsoleKey.NumPad3: SeatSelection(); break; case ConsoleKey.D4: case ConsoleKey.NumPad4: SeatSelection(); break; case ConsoleKey.D5: case ConsoleKey.NumPad5: carryOn = false; break; default: Console.WriteLine("Please enter a valid number! "); validInput = false; break; } } while (!validInput); return carryOn; } private void SeatSelection() { Console.Clear(); Console.WriteLine("Please select first or third class for your trip. "); Console.WriteLine("1) First"); Console.WriteLine("2) Third"); Console.WriteLine("3) Return to booking main menu"); bool validInput = false; do { validInput = true; ConsoleKeyInfo key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: FirstClass(); break; //case ConsoleKey.D2: //case ConsoleKey.NumPad2: // ThirdClass(); // break; case ConsoleKey.D3: case ConsoleKey.NumPad3: WelcomeMenu(); break; default: Console.WriteLine("Please enter a valid number!"); validInput = false; break; } } while (!validInput); } private void FirstClass() { Random rnd = new Random(); int[] numbers = new int[4] { 1, 2, 3, 4 }; int mIndex = rnd.Next(0, numbers.Length); Console.WriteLine("Your assigned compartment is "); Console.WriteLine(numbers[mIndex]); Console.ReadLine(); } } } 

by MoultonWarrior via /r/csharp

Leave a Reply