In a windows forms application you can register event handlers like this:
this.KeyDown += new KeyEventHandler(Form1_KeyDown);
and later unregister the same handler like this:
this.KeyDown -= new KeyEventHandler(Form1_KeyDown);
To me this seems odd because I would expect the -= to require the same handler that was registered originally, not a second new handler of the same signature. But from experience I know this works. This led me to think that this was a special case and in reality
Form1_KeyDown == new KeyEventHandler(Form1_KeyDown)
Based on that theory I have often rewritten my code to register and unregister events like this:
this.KeyDown += Form1_KeyDown;
Is this safe? Or will this have some unintended side effect I don't realize?