January 14

Lambda Expressions Resolution in C#

0  comments

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.

Tags


You may also like

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Subscribe to our newsletter now!

Get instant access to the Master C# 9 webinar to learn all the new exciting C# 9 features quickly.
Get regular videos and news on C# and .NET and offers on products and services to master C#.

We will collect, use and protect your data in accordance with our Privacy Policy.

>