Why am i not allowed to use this string inside the if-bracket? : <p>This maybe a silly question with a simple solution, but i cant figure out why it doesn't let me use the string "datatxt" inside the if-bracket. It says, "The name 'datatxt' does not exist in the current context". Any help is apprechiated.</p>

<pre><code>        try
        {      
            StreamReader sr = new StreamReader("Data.txt");
            String datatxt = sr.ReadLine();
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error har occured: '{0}'", ex);
        }

        if (UserBox.Text.Equals(user) &amp;&amp; PassBox.Text.Equals(data + datatxt)) 
        {
            Main s = new Main(); 
            s.Show();                  
            this.Hide(); 
</code></pre>
