title: declare variable outside of the foreach loop
body: <p>In for loop case I can declare the index outside the for statement. For example, instead of</p>
  
  <pre><code>for (int i = 0; i &lt; 8; i++) { }
  </code></pre>
  
  <p>I can do:</p>
  
  <pre><code>int i;
  for (i = 0; i &lt; 8; i++) { }
  </code></pre>
  
  <p>Now in compare to foreach loop, I have to declare the variable inside the loop:</p>
  
  <pre><code>foreach (string name in names) { }
  </code></pre>
  
  <p>And I cannot do something like:</p>
  
  <pre><code>string name;
  foreach (name in names) { }
  </code></pre>
  
  <p>The reason this bothers me is that after the loop I want to use the variable "name" again. In case of foreach loop the variable "name" can't be used since it outside of the foreach scope, and I cannot declare another variable with the same name since it declared before in the same scope.</p>
  
  <p>Any idea?</p>