Jie*_*eng 5 c# lambda delegates anonymous-function
我只想验证我对以下内容的理解
嗯...他们都做类似的事情,你如何定义和知道何时使用每个?
对不起,我不好解释
委托 - 它不是方法签名.It is a type which encapsulates a method.因此,委托声明应该具有与其想要封装的方法类似的签名.When to use Delegate - whenever you want to pass a method to another function.欲了解更多看到这个和这个.
Lambdas - 写一个匿名函数的简短手和更具表现力的方式.但还有更多.lambda表达式也可以转换为表达式树.欲了解更多看到这个.
匿名函数 - 是的......就是这样
Action - 它是一个委托,它可以封装一个不返回任何内容的函数.因此,您应该将其视为a type that can encapsulate an action并在需要传递操作时使用它.
Func - 可以封装返回某些内容的函数的委托.但是你应该把它当作a type that can encapsulate a transformation想要传递转换的时候使用.
| 归档时间: |
|
| 查看次数: |
1797 次 |
| 最近记录: |