What does '=>' do in C #?

Possible duplicates:
Lamda Explanation and what it is, as well as a good example
What is => is the token called?

I saw this code:

myContext.SomeEntities.Single(x => x.code == code);  

And I don't know what the => operator does.

Every google search about a statement does not return results.

Thank.

+5
source share
5 answers

The operator =>stands for Lambda Expression :

A lambda expression is an anonymous function that can contain expressions and statements and can be used to create delegates or types of expressions tree.

- - = > , "". ( ), . - x = > x * x "x x x". :

static void Main(string[] args)
{
    Func<int, int> func = x => x * x;
    int j = func(5);
    // j == 25
}
+15

. "x x.code equals code", , x .

+2

They are associated with lambda expressions.

You can read about lambda expressions here: http://www.rvenables.com/2009/03/practical-introduction-to-lambda-expressions/

+1
source

All Articles