title: What does "DisplayClass" name mean when calling lambda?
body: <p>According to <a href="https://stackoverflow.com/a/6014613/57428">this answer</a> when code uses local variables from inside lambda methods the compiler will generate extra classes that can have name such as <code>c__DisplayClass1</code>. For example the following (completely useless) code:</p>
  
  <pre><code>class Program
  {
      static void Main()
      {
          try {
              implMain();
          } catch (Exception e) {
              Console.WriteLine(e.ToString());
          }
      }
  
      static void implMain()
      {
          for (int i = 0; i &lt; 10; i++) {
              invoke(() =&gt; {
                  Console.WriteLine(i);
                  throw new InvalidOperationException();
              });
          }
      }
      static void invoke(Action what)
      {
          what();
      }
  }
  </code></pre>
  
  <p>outputs the following call stack:</p>
  
  <pre><code>System.InvalidOperationException
  at ConsoleApplication1.Program.&lt;&gt;c__DisplayClass2.&lt;implMain&gt;b__0()
  at ConsoleApplication1.Program.invoke(Action what)
  at ConsoleApplication1.Program.implMain()
  at ConsoleApplication1.Program.Main()
  </code></pre>
  
  <p>Note that there's <code>c__DisplayClass2</code> in there which is a name of a class generated by the compiler to hold the loop variable.</p>
  
  <p>According to <a href="https://stackoverflow.com/a/2509524/57428">this answer</a> <code>c__DisplayClass</code> "means"</p>
  
  <blockquote>
    <p>c --> anonymous method closure class ("DisplayClass")</p>
  </blockquote>
  
  <p>Okay, but what does "DisplayClass" mean here?</p>
  
  <p>What does this generated class "display"? In other words why is it not "MagicClass" or "GeneratedClass" or any other name?</p>