C# the name 'sr' doesn't exist in current context
<p>I was following example from microsoft <a href="http://msdn.microsoft.com/en-us/library/db5x7c0d.aspx" rel="nofollow">site</a> for reading from text file. They say to do it like this:</p>

<pre><code>using System;
using System.IO;

class Test
{
    public static void Main()
    {
        try
        {
            using (StreamReader sr = new StreamReader("TestFile.txt"));
            {
                String line = sr.ReadToEnd();
                Console.WriteLine(line);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("The file could not be read:");
            Console.WriteLine(e.Message);
        }
    }
}
</code></pre>

<p>but when I do it like that in Visual C# 2010 it brings me errors:</p>

<blockquote>
  <p>Possible mistaken empty statement</p>
  
  <p>The name 'sr' does not exist in current context</p>
</blockquote>

<p>I removed the <code>using</code> part and now the code looks like this and is working:</p>

<pre><code>try
   {
   StreamReader sr = new StreamReader("TestFile.txt");
                    String line = sr.ReadToEnd();
                    Console.WriteLine(line);

            }
</code></pre>

<p>Why is that?</p>

<p>EDIT: there was semicolon at te end of using(....);</p>
