" mean? What does => mean? Copy the code here: Dispatcher.BeginInvoke((Action)(() => { trace.Add(response); })); +6 c # lambda w...">

What does "=>" mean?

What does => mean? Copy the code here:

 Dispatcher.BeginInvoke((Action)(() => { trace.Add(response); })); 
+6
source share
7 answers

it is a lambda expression that is the simplified syntax of an anonymous delegate. he reads "coming." equivalent to Dispatcher.BeginInvoke((Action)delegate() { trace.Add(response); });

+7
source

=> is the lambda expression operator, which indicates that the code is a lambda expression.

 ( param ) => expr(int x) = > { return x + 1 }; 

or

 param => exprx=> x + 1;> 

What is a Lambda expression?

 * Lambda expression is replacement of the anonymous method avilable in C#2.0 Lambda expression can do all thing which can be done by anonymous method. * Lambda expression are sort and function consist of single line or block of statement. 

Read More: Lambda Expressions

+2
source

=> - an operator called a lambda operator

Used to create a lambda expression.

+1
source
+1
source

This is a lambda operator that reads as "going to"

0
source

This "=>" means using the syntax of a lambda expression in C #.

This syntax is available with Visual Studio 2008 in .NET 3.5 (C # 3.0). This is the official MSDN documentation for lambda expressions in C # .

The above code is the same as an anonymous delegate already available with C # 2.0

Your code:

 Dispatcher.BeginInvoke((Action)(() => { trace.Add(response); })); 

converted to:

 Dispatcher.BeginInvoke(new delegate () { trace.Add(response); }); 

These two codes essentially have the same semantics.

0
source

It's worth noting that a single lambda expression doesn't need {} around the body, and it doesn't need a semicolon, so you can simplify your code a bit.

 Dispatcher.BeginInvoke((Action)(() => trace.Add(response) )); 
0
source

Source: https://habr.com/ru/post/898258/


All Articles