Introduction
Lambda Expression concept was introduced in C# 3.0 . Lambda expression can be
assumed as a more concise syntax of anonymous method. Anonymous methods can be
written with C Sharp Lamda Expression. At the time of Compilation lambda
expression converted in anonymous method , It is a Lambda expression conversion
rule. On Left side of Lambda operator β=>β represent the argument to the method
and on right side method body.
Syntax
(parameters) => expression or _statement block
Types
There are basically 2 types of Lambda expression
1. Statement Lambda: It has a statement block on the right side of lambda
operator β=>β
for example i=> (return i*I ;);
2. Expression Lambda: It has only an expression k=>k*k; // here k*k is
expression
Features
- Lambda expression does not have type. In CLR there is no concept of
Lambda.
- Jump statements are not allowed within anonymous method/lambda
expression.
- Lambda expression generally used with the Function and action Delegate.
- Variables which are defined within a lambda expression , has the scope
only within the Lambda expression body.