title: Small coding project won't catch FormatException
body: <p>So I recently started my first coding course for C#. I am currently trying to write a short program that prints out Yay! as many times as I indicate. Now to prevent any format exceptions, I've tried to add a try and catch to it. But, for some reason this isn't working and I can't seem to figure out why. The code is below:</p>
  
  <pre><code>  Console.Write("Enter the number of times to print \"Yay!\": ");
    string entry = Console.ReadLine();
    var number = int.Parse (entry);
    bool print = true;
    while(print)
    {
      try
      {
        if(number &lt;= 0)
        {
          print = false;
        }
        else
        {
          Console.WriteLine("Yay!");
          number -= 1;
        }
      }
      catch(FormatException)
      {
        Console.WriteLine("You must enter a whole number.");
      }
    } 
  </code></pre>
  
  <p>Now to my knowledge, I have everything I need to make this work. Can anyone see where I went wrong with this?</p>
  
  <p>Thanks a lot for reading!</p>