title: In a `while` loop, why can't I declare variable in the condition as in a `for` loop?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1581364/why-cant-we-define-a-variable-inside-a-while-loop">why can&#39;t we define a variable inside a while loop?</a>  </p>
  </blockquote>
  
  
  
  <p>I would like to simplify the following code:</p>
  
  <pre><code>string line;
  while ((line = sr.ReadLine()) != null)
  </code></pre>
  
  <p>into:</p>
  
  <pre><code>while ((string line = sr.ReadLine()) != null)
  </code></pre>
  
  <p>but failed.</p>
  
  <p>However, we surely can do this in <code>for</code>:</p>
  
  <pre><code>for (int i=0, int n=50;i&lt;n;i++)
  </code></pre>