title: C# Parse string integer error?
body: <p>I've literally just started C#... Today and I'm attempting to write a very simple application. However, when I use the console.readkey if anything other than a number is entered, it immediately crashes. </p>
  
  <p>I completely understand that its attempting to parse out the numbers and convert them to a string however though, How do I keep the application from crashing or failing if someone doesn't insert a number. I've googled around but apparently this is a pretty specific thing.</p>
  
  <p>All I'm trying to do is nullify or Parse out anything that's not numbers so the application doesn't get confused and shut down.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace ConsoleApplication3
  {
      class Program
      {
          static void Main(string[] args)
          {
          Console.Write("what is your age?");
          string agestring = Console.ReadLine();
          int age = Int32.Parse(agestring);
  
          if (age &gt;= 21)
          {
              Console.WriteLine("congrats, you're you can get drunk!");
  
          }
          else if (age &lt; 21)
          {
              Console.WriteLine("Sorrrrrryyyyyyy =(");
          }
          else
          {
              Console.WriteLine("Sorry Thats not a valid input");
          }
      }
  }
  </code></pre>