Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 什么是'=&燃气轮机';什么意思?_C#_Lambda - Fatal编程技术网

C# 什么是'=&燃气轮机';什么意思?

C# 什么是'=&燃气轮机';什么意思?,c#,lambda,C#,Lambda,=>是什么意思?下面是一个代码快照: Dispatcher.BeginInvoke((Action)(() => { trace.Add(response); })); =>是一个称为Lambda运算符的运算符 它用于创建表示代码为lambda表达式的is lambda表达式运算符 ( param ) => expr(int x) = > { return x + 1 }; 或 什么是Lambda表达式? * Lambda expression is replacement

=>
是什么意思?下面是一个代码快照:

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

=>是一个称为Lambda运算符的运算符


它用于创建表示代码为lambda表达式的is lambda表达式运算符

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

什么是Lambda表达式?

* 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.

阅读更多信息:

这是lambda表达式,它是匿名委托的简化语法。上面写着“去”。相当于
Dispatcher.BeginInvoke((操作)委托(){trace.Add(响应);})

这是一个lambda运算符,读起来像“goes to”

这个“=>”表示在C#中使用lambda表达式语法

此语法自Visual Studio 2008在.NET 3.5(C#3.0)中提供以来一直可用。这是最新的

上面的代码与C#2.0以来已经提供的中的匿名委托相同

您的代码:

Dispatcher.BeginInvoke((Action)(() => { trace.Add(response); })); 
翻译成:

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

这两个代码本质上具有相同的语义。

值得注意的是,单个表达式lambda不需要主体周围的{},也不需要分号,因此您可以将代码(稍微)简化为


此外,您正在查看的示例使理解Lambda操作符的功能变得非常困难。请看下面的一些例子和下面的链接。如果你得到了你想要的信息,不要忘记将答案标记为已接受。我认为这个问题会激发出许多具有类似含义的答案。
Dispatcher.BeginInvoke(new delegate () { trace.Add(response); });
Dispatcher.BeginInvoke((Action)(() => trace.Add(response) ));