0
创建事件时,发送EventArgs
对象作为第二个参数是标准操作。但是,事件往往只需要发送一个数据,比如一个字符串或int。据我所知,你不能真正对EventArgs
类做任何事情。在没有EventArgs的情况下创建事件
那么是否真的有必要创建一个带有一个字段的全新类,以仅用于发送带有事件的简单字符串/ int?
例
public delegate void JoinButtonEvent(object sender, string buttonId);
VS
public delegate void JoinButtonEvent(object sender, JoinButtonEventArgs e);
凡JoinButtonEventArgs
是与场的一类称为buttonId
。
它是否编译?那么这是没有必要的。 –
看看这个:http://stackoverflow.com/questions/3312134/does-net-have-a-built-in-eventargst – n8wrl