What is => ? What is it called and what does it do? C#.

The ‘lambda operator’. It’s read as ‘goes to’. As in, x => 2 * x is read as “x goes to 2 times x .”

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. Lambda expressions are particularly helpful for writing LINQ query expressions.

To create a lambda expression, you specify input parameters (if any) on the left side of the lambda operator =>, and you put the expression or statement block on the other side. For example, the lambda expression x => x * x specifies a parameter that’s named x and returns the value of x squared.

via ms docs

Leave a Reply