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