Explain how lambdas are compiled : <p>From the book C# in Depth</p>

<pre><code>static void Main()
{
    // First build a list of actions
    List&lt;Action&gt; actions = new List&lt;Action&gt;();
    for (int counter = 0; counter &lt; 10; counter++)
    {
        actions.Add(() =&gt; Console.WriteLine(counter));
    }

    // Then execute them
    foreach (Action action in actions)
    {
        action();
    }
} 
</code></pre>

<p>this will print 10 10 10...</p>

<pre><code>static void Main()
{
    // First build a list of actions
    List&lt;Action&gt; actions = new List&lt;Action&gt;();
    for (int counter = 0; counter &lt; 10; counter++)
    {
        int copy = counter;
        actions.Add(() =&gt; Console.WriteLine(copy));
    }

    // Then execute them
    foreach (Action action in actions)
    {
        action();
    }
} 
</code></pre>

<p>this will print 10 9 8 ..</p>

<p>I dont understand why</p>
