特別是在事件的情況下,我想知道是否有很好的理由選擇一個在另一個之上?通過參數發送相關數據或通過getter訪問?
C#例如:
Class A
public event System.Action<someparam> someevent;
Class B
void eventcalledmethod(someparam param){
//do something with param
}
比。
Class A
public event System.Action();
public static someparam Getter{get;}
Class B
void eventcalledmethod(){
//do something with A.Getter
}
第二個示例用於Microsoft Windows C++ API中,用於處理窗口事件。
你真的應該使用https://codereview.stackexchange.com/,因爲這不是真正的問題,因爲它不在這裏工作是我的嘗試。 – rogue39nin
嘿,謝謝你的提示,不知道我在哪裏發佈這個 –