C# Error in variable declaration using if statement
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2496589/variable-declarations-following-if-statements">Variable declarations following if statements</a><br>
  <a href="http://stackoverflow.com/questions/8823427/why-this-compile-error">Why this compile error</a>  </p>
</blockquote>



<p>I am getting the error "Embedded statement cannot be a declaration or labeled statement" because I had a declaration of a variable following an if statement with no brackets.  Anyway, that's the background, which brings me to this.</p>

<p>The following code is illegal</p>

<pre><code>if (true) int i = 7;
</code></pre>

<p>However, if you wrap that in brackets, it's all legal.</p>

<pre><code>if (true){ int i = 7;}
</code></pre>

<p>Neither piece of code is useful. Yet the second one is OK. What specifically is the explanation for this behavior?</p>
