什么是运营商= GT;'在C#是什么意思? [英] What does the operator '=>' mean in C#?
本文介绍了什么是运营商= GT;'在C#是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是'=>'在此声明意味着
What does the '=>' in this statement signify?
del = new SomeDelegate(() => SomeAction());
时的上述声明一样,因为这一个?
Is the above declaration the same as this one?
del = new SomeDelegate(this.SomeAction);
感谢。
Thanks.
推荐答案
基本上它指定一个匿名函数,不带参数调用SomeAction。所以,是的,他们在功能上等同。虽然不相等。使用拉姆达更等同于:
Basically it's specifying an anonymous function, that takes no parameters that calls SomeAction. So yes, they are functionally equivalent. Though not equal. Using the lambda is more equivalent to:
del = new SomeDelegate(this.CallSomeAction);
在这里CallSomeAction定义为:
where CallSomeAction is defined as:
public void CallSomeAction()
{
this.SomeAction();
}
希望帮助!
Hope that helps!
这篇关于什么是运营商= GT;'在C#是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文