Javatpoint Logo
Javatpoint Logo

C# Anonymous Functions

Anonymous function is a type of function that does not has name. In other words, we can say that a function without name is known as anonymous function.

In C#, there are two types of anonymous functions:

  • Lambda Expressions
  • Anonymous Methods

C# Lambda Expressions

Lambda expression is an anonymous function which we can use to create delegates. We can use lambda expression to create local functions that can be passed as an argument. It is also helpful to write LINQ queries.

C# Lambda Expression Syntax

Example

Output:

Square: 25

C# Anonymous Methods

Anonymous method provides the same functionality as lambda expression, except that it allows us to omit parameter list. Let see an example.

Example

Output:

This is anonymous function

Next TopicC# Multithreading





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA