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.
精彩评论