How do lambda expressions work internally?
I did a fairly extensive blog series on how closures work internally. It's written for the VB.Net implementation of closures but the underlying details are very similar to C#'s. It should provide the answers you're looking for
Here is the link to part 6 which links to all of the other articles
- http://blogs.msdn.com/jaredpar/archive/2007/08/06/closures-in-vb-part-6-limitations.aspx
Jon Skeet wrote an in-depth description.
Basically, the compiler turns the outer method into a class, and turns all of the variables that are accessed by the anonymous methods into fields on the class. The anonymous methods become regular instance methods on the class.