April 2013
Intermediate to advanced
1700 pages
92h 51m
English
As mentioned in Chapter 20, lambda expressions have two representations. One is the equivalent to anonymous methods, causing the lambda expression to be translated into a piece of IL code that allows direct execution of its logic:
Func<int, int, int> f = (a, b) => (a + b) * 2;
This is the same as the following C# 2.0 fragment:
Func<int, int, int> f = delegate (int a, int b) { return (a + b) * 2; };
The preceding can be translated into a separate method that’s being referred to by the delegate:
Func<int, int, int> f = new Func<int, int, int>(MyExpression);...static int MyExpression(int a, int b) { return (a + b) * 2; }
However, when we assign the lambda expression to an Expression<T> ...
Read now
Unlock full access