C# Lambda Expression

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

  1. Lambda expression does not have type. In CLR there is no concept of Lambda.
  2. Jump statements are not allowed within anonymous method/lambda expression.
  3. Lambda expression generally used with the Function and action Delegate.
  4. Variables which are defined within a lambda expression , has the scope only within the Lambda expression body.
Next Recommended Reading Lambda Expression In C#