Lambda Expressions Resolution in C#
- By C#
January 14, 2013
Consider the code:
How this type of lambda expression is translated by the C# compiler?
The compiler internally resolves this type of lambda expressions by writing a private method and moving the expressions’s code into that method.
It is possible to verify this using a free .NET decompiler like dotPeek.
Why this is relevant?
I am a strong believer that is important to understand what happens under the covers because it gives you a broader perspective and a better awareness of how the code works.
There are plenty of features of the C# languages that actually maps themselves to a subset of the C# language. This is one of the best thing of C# because this features usually improve significantly the developers productivity. The price is that something magic happens under the cover and this is why is important to learn about them.
Permanent link to this article: https://www.productivecsharp.com/2013/01/lambda-expressions-resolution-in-c/