title: Why can't I declare a variable in body of a "do while" loop?
body: <p>I should be able to do this. The "do while" executes the instructions and declares the variable and after compare.</p>
  
  <pre><code>Random rnd = new Random();
  
  do{
      int number= rnd.Next();
  } while (number != 0)
  </code></pre>
  
  <p>The problem is the scope, for example, i can compile the next code:</p>
  
  <pre><code>Random rnd = new Random();
  int number;
  
  do{
       number= rnd.Next();
  } while (number != 0)
  </code></pre>