Anonymous Methods in Action
Understanding Lambda Expressions
Assigning a Lambda to a Delegate
Handling Empty Parameters
Delegates that don't accept any parameters can be handled using lambdas:
Delegates in .NET
The .NET framework provides several different delegates that provide flexible options:
- Action
- Accepts a single parameter and returns no value - Func
- Accepts a single parameter and return a value of type TResult
Using Action
Action can be used to call a method that accepts a single parameter of type T:
Using Func
Func supports a single parameter (T) and returns a value (TResult):
Summary
- Lambdas provide a way to define inline methods using a concise syntax
- The .NET Framework provides several built-in delegate types such as:
- Action
- Func
Please find below link of source code providing example.
No comments:
Post a Comment