title: Declaring variable within 'while loop' but can't change value during loop
body: <p>I'm trying to make this loop work so it will keep asking for a number until the user enters 999. However with this version of code, it won't build saying I can't declare num within the loop becuase I'm giving it different meaning in this scope. </p>
  
  <p>The try and catch are used because of my assignment rules for this piece of code.</p>
  
  <pre><code>int num;
  while (num != 999)
  {
      Console.WriteLine("Enter a number between 0 and 99");
      string input = Console.ReadLine();
      try
      {
          int num = Convert.ToInt32(input);
          Console.WriteLine("This is element number " + num + " : " + randNums[num]);
      }
      catch
      {
          Console.WriteLine("Data inputted is not between 0 and 99");
      }
  }
  Console.WriteLine("You chose the secret value, well done!");
  </code></pre>