Lambda Expressions in C#

Lambda Expressions in C#
“Lambda Expressions” are “name-less methods”, that can be invoked by using the delegate variable or an event, much like anonymous methods.
 
Handle Event with Lambda Expressions:
EventName += (param1, param2, …) =>
{
  //method body here
}
 
Lambda Expressions can be used anywhere within the method, to create methods instantly, without define a method at the class level.
 
Inline Lambda Expressions are the lambda expressions, which performs a small calculation or condition check and returns a value.
Inline lambdas can receive one or more arguments and must return a value.
 
 Handle Event with Inline Lambda Expressions:
EventName += (param1, param2, …) => condition or calculation

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply