title: How to modify object from a lambda expression body used in Linq Extension method?
body: <p>I want the side effect when using lambda expression with <code>Select</code> extension method, something like this:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  
  namespace SyntaxExperiment {
  
      public class Program {
          static void Main() {
              var list = new List&lt;int&gt;();
              var results = new[] { 1, 2, 3 }
                  .Select(
                      i =&gt; {
                          list.Add(i);
                          return i;
                      }   
                  );
              Console.WriteLine(list.Count);
          }
      }
  }
  </code></pre>
  
  <p>The code above outputs:</p>
  
  <pre><code>0
  </code></pre>
  
  <p>How is this possible?</p>