C# Anonymous Function - Anonymous Method in C#
C# Anonymous Function
- Anonymous function is a type of function that does not has name and we can say that a function without name is known as anonymous function.
- In C# anonymous function consists of two types, they are:
- Lambda Expressions
- Anonymous Methods
C# Lambda Expressions
- Lambda expression is an anonymous function which we can use to create delegates and it is also helpful to write LINQ queries.
- Here, we can use lambda expression to create local functions that can be passed as an argument.
Syntax
(input-parameters) => expression
Sample Code
Output
C# Anonymous Methods
- Anonymous method provides the same functionality as lambda expression, except that it allows us to omit parameter list.