假设我要在分配事件处理程序时传递一些额外的数据。考虑以下代码:
private void setup(string someData) { Object.assignHandler(evHandler); } public void evHandler(Object sender) { // need someData here!!! }
我将如何someData进入我的evHandler方法?
someData
evHandler
private void setup(string someData) { Object.assignHandler((sender) => evHandler(sender,someData)); } public void evHandler(Object sender, string someData) { // need someData here!!! }