title: C# Closures, why is the loopvariable captured by reference?
body: <p>In this example, I'm attempting to pass by value, but the reference is passed instead.</p>
  <pre><code>for (int i = 0; i &lt; 10; i++)
  {
      Thread t = new Thread(() =&gt; new PhoneJobTest(i));
      t.Start();
  }
  </code></pre>
  <p>This can be remedied like so:</p>
  <pre><code> for (int i = 0; i &lt; 10; i++)
  {
      int jobNum = i;
      Thread t = new Thread(() =&gt; new PhoneJobTest(jobNum));
      t.Start();
  }
  </code></pre>
  <p>What's is going on here?  Why does the original example pass the reference?</p>