Lambda Expressions as Shorthand for Delegate C# with Example



Lambda Expressions as Shorthand for Delegate C# with Example

Initialization 
public delegate int ModifyInt(int input); 
ModifyInt multiplyByTwo = x => x * 2; 
The above Lambda expression syntax is equivalent to the following verbose code: 
public delegate int ModifyInt(int input); 
ModifyInt multiplyByTwo = delegate(int x){ 
return x * 2; 
}; 

0 Comment's

Comment Form

Submit Comment