开发者

Overloading Method To Allow Adding It As Event Handler?

I'm overloading a method so it can be assigned to an event. There has to be a better way to do this.

myMethod(){
    //Does some stuff...
}
myMethod(object sender, FormClos开发者_开发问答ingEventArgs e){
    myMethod();
}

Form.FormClosing += new FormClosingEventHandler(myMethod);


An anonymous method works well here:

form.FormClosing += delegate { myMethod(); };

The compiler pretty much does what you did, but with less plumbing code to read.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜