C# Lambda ( => )
可能的重复:
优秀的 lambda 教程
Lambda 解释及其含义一个很好的例子
C# Lambda 表达式,我为什么要使用它?
有人可以吗向我解释如何使用它并给我例子?我们如何阅读它?
示例 !=
读作“不等于”。那么 =>
意味着什么?
Possible Duplicates:
Good tutorials for lambda
Lambda Explanation and what it is as well as a good example
C# Lambda expression, why should I use this?
Can someone explain to me how to use this and give me examples? How do we read it?
Example !=
is read as "not equals to." So =>
means what?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来自 docs
From the docs
“=>”是 lambda 运算符,读作“前往”
"=>" is lambda operator and is read as "goes to"
这就是 lambda 运算符。这意味着“去”。它用于创建 lambda 表达式,这是 C# 为匿名方法提供的语法。
例如。 lamda 表达式 x=>x > 2.。这意味着给定 x,x 会选择大于 2 的 x。换句话说,此 lambda 表达式将选择大于 2 的 x。
相同的匿名方法可以写为
This is the lambda operator. Which means 'goes to'. It is used to create lambda expressions which is syntax offered by C# for anonymous methods.
eg. lamda expression
x=>x > 2
. This mean that given x, x goes to x greater than 2. In other words this lambda expression will select x greater than 2.Anonymous method for the same can be written as
http://msdn.microsoft.com/en-us/library/bb397687.aspx
=>运算符与赋值 (=) 具有相同的优先级,并且是右结合的。
http://msdn.microsoft.com/en-us/library/bb397687.aspx
The => operator has the same precedence as assignment (=) and is right-associative.