C# Lambda ( => ) [英] C# Lambda ( => )

查看:12
本文介绍了C# Lambda ( => )的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
关于 lambda 的好教程
Lambda 解释以及它是什么作为一个很好的例子
C# Lambda 表达式,我为什么要使用这个? >

有人可以向我解释如何使用它并举例说明吗?我们如何阅读?

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?

推荐答案

所有的 lambda 表达式都使用 lambda运算符 =>,读作去to".lambda的左侧运算符指定输入参数(如果有)和右侧保存表达式或语句堵塞.lambda 表达式 x => x *x 读作x 到 x 次 x".这表达式可以赋值给委托类型如下:

All lambda expressions use the lambda operator =>, which is read as "goes to". The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression or statement block. The lambda expression x => x * x is read "x goes to x times x." This expression can be assigned to a delegate type as follows:

来自文档

=> 运算符具有与赋值 (=) 相同的优先级并且是右结合的.

the => operator has the same precedence as assignment (=) and is right-associative.

这篇关于C# Lambda ( => )的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆