有没有在C#中附加事件处理程序的两种不同的方式产生实际差异? [英] Is there an actual difference in the 2 different ways of attaching event handlers in C#?
本文介绍了有没有在C#中附加事件处理程序的两种不同的方式产生实际差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C#有没有之间的引擎盖下的任何真正的区别(除了语法等):
In C# is there any real difference (other than syntax) under the hood between:
myButton.Click += new EventHandler(myMemberMethod);
和
myButton.Click += myMemberMethod;
推荐答案
第二种方法是一个快捷方式到第一位,据介绍在C#2.0
The second method is a shortcut to the first one, it was introduced in C# 2.0
又见<一个href=\"http://stackoverflow.com/questions/119160/what-is-the-difference-between-events-with-delegate-handlers-and-those-without\">this螺纹。
这篇关于有没有在C#中附加事件处理程序的两种不同的方式产生实际差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文