How do I use TryParse or Try catch to explain to the user what he's doing wrong?
<p>So I'm new to programming and can't seem to figure out how to solve this problem that I've got. When the user enters a letter instead of a number I want to explain to him what he did wrong. I've set up a try catch but I get an error that says "Use of unassigned local variable 'number' ".</p>

<p>Would really appreciate any help! 
/Alex</p>

<pre><code>namespace ConsoleApplication3
{
class Program
{
    static void Main(string[] args)
    {
        // variables
        Random slumpat = new Random(); 
        int gameNumber = slumpat.Next(1, 20); 
        int number;

        bool play = true; 

        while (play)
        {
            Console.Write("\n\tGuess a number between 1 and 20: ");
        try {
            Int32.TryParse(Console.ReadLine(), out number);
            }
        catch 
            {
            console.WriteLine("This only works with numbers!");
            }

            if (number &lt; gameNumber)
            {

                Console.WriteLine("\tThe number you entered " + number + " is too small, try again.");
            }

            else if (number &gt; gameNumber)
            {
                Console.WriteLine("\tThe number you entered " + number + " is too big, try again.");
            }

            else if (number == gameNumber)
            {
                Console.WriteLine("\tYou guessed right!");
                play = false;
            }

        }

    }
}
}
</code></pre>