title: How do I return string value if consoleKey.Escape hasn't been pressed?
body: <p>I have a basic console application. Users can select from a numbered menu, 1-5. If they press ESC the program closes but if they don't press ESC a <code>switch</code> is used to determine which option they chose by which string they input (1, 2, 3, 4 or 5).</p>
  
  <p>This code isn't working:</p>
  
  <pre><code>static string mainMenu()
          {
      string menuOption;
  
          // get user input
          ConsoleKeyInfo option = Console.ReadKey();
          if (option.Key == ConsoleKey.Escape)
          {
  
             Environment.Exit(0);
          }
  
          return menuOption = Console.ReadLine();
  }
  </code></pre>
  
  <p>How can I get the string value of what the user input in to <code>menuOption</code> whilst also checking if the user pressed <code>ESC</code>?</p>