title: C# add delegate in list
body: <p>this below example print only 10 for ten times.
  could you please tell me whats going in background.</p>
  
  <pre><code> public delegate void DoSomething();
  
  static void Main(string[] args)
  {
      List&lt;DoSomething&gt; lstOfDelegate = new List&lt;DoSomething&gt;();
      int iCnt = 0;
      while (iCnt &lt; 10)
      {
          lstOfDelegate.Add(delegate { Console.WriteLine(iCnt); });
          iCnt++;
      }
  
      foreach (var item in lstOfDelegate)
      {
          item.Invoke();
      }
      Console.ReadLine();
  }
  </code></pre>
  
  <p>accroding to me it should print 0 To 9, but it print 10,10,10,10,10,10,10,10,10,10</p>