Tag: 代表

代表们的优势是什么?

使用代表有什么好处/好处? 有人能提供任何简单的例子吗?

代表的目的

重复: 事件和代表之间的差异及其各自的应用程序 代表们的优势是什么? 我在哪里使用代表? 我想知道代表们的目的是什么。 我没有那么多地使用它们,也不能真正想到什么。 在我的课程中,有人写道,代表是符合其签名的所有方法的蓝图。 此外,您可以向一个委托添加多个方法,然后按照添加顺序在彼此之后执行它们。 这可能仅对影响局部变量的方法或不返回任何值的方法有用。 我已经读过C#将Events实现为委托,记录为: //Summary: Represents the method that will handle an event that has no event data. //Parameters: //sender: The source of the event. //e: An System.EventArgs that contains no event data. [Serializable] [ComVisible(true)] public delegate void EventHandler(object sender, EventArgs e); 不过,这有点令人困惑。 有人可以给出这个概念的一个好的,有用的例子吗?