Stats

741 Contributors: 21 Thursday, April 27, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Lambda expressions

Remarks

A lambda expression is a syntax for creating anonymous functions inline. More formally, from the C# Programming Guide:

A lambda expression is an anonymous function that you can use to create delegates or expression tree types. By using lambda expressions, you can write local functions that can be passed as arguments or returned as the value of function calls.

A lambda expression is created by using the => operator. Put any parameters on the lefthand side of the operator. On the righthand side, put an expression that can use those parameters; this expression will resolve as the return value of the function. More rarely, if necessary, a whole {code block} can be used on the righthand side. If the return type is not void, the block will contain a return statement.

Related Examples