在C#中附加事件处理程序的两种不同方法有实际的区别吗? [英] Is there an actual difference in the 2 different ways of attaching event handlers in C#?
本文介绍了在C#中附加事件处理程序的两种不同方法有实际的区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
myButton.Click + = new事件处理程序(myMemberMethod);
和
myButton.Click + = myMemberMethod;
?
解决方案
第二种方法是第一种方法的快捷方式,它在C#2.0中引入
另请参见 this thread 。
In C# is there any real difference (other than syntax) under the hood between:
myButton.Click += new EventHandler(myMemberMethod);
and
myButton.Click += myMemberMethod;
?
解决方案
The second method is a shortcut to the first one, it was introduced in C# 2.0
See also this thread.
这篇关于在C#中附加事件处理程序的两种不同方法有实际的区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文