Monday, August 15, 2011

What is Lambda Expressions? How can we optimize our linq code using this Expression?

Lambda expressions can be considered as a functional superset of anonymous
methods, providing the following additional functionality:

Lambda expressions can infer parameter types, allowing you to omit them.

Lambda expressions can use both statement blocks and expressions as bodies,
allowing for a terser syntax than anonymous methods, whose bodies can
only be statement blocks.

Lambda expressions can participate in type argument inference and
method overload resolution when passed in as arguments. Note: anonymous
methods can also participate in type argument inference (inferred return types).


In C#, a lambda expression is written as a parameter list, followed by the => token,followed by an expression or a statement block

No comments:

Post a Comment