Basic lambda expressions C# with Example



Basic lambda expressions C# with Example

Func add1 = i => i + 1; 
Func add = (i, j) => i + j; 
 

// Behaviourally equivalent to: 
int Add1(int i) 
{ 
return i + 1; 
} 
int Add(int i, int j) 
{ 
return i + j; 
} 
... 
Console.WriteLine(add1(42)); //43 
Console.WriteLine(Add1(42)); //43 
Console.WriteLine(add(100, 250)); //350 
Console.WriteLine(Add(100, 250)); //350 

0 Comment's

Comment Form

Submit Comment