tags:

views:

80

answers:

2

Hi, I simply do not understand why both works:

this.timer.Tick += new EventHandler(timer_Tick);
this.timer.Tick += classA.Tick;

Thanks

+6  A: 

Starting from v2.0 (AFAIR) of C#, EventHandler (and other delegates too) is instantiated implicitly. If you'll decompile your code you'll see that.

elder_george
cool didn't know
JohnIdol
learned it recently too after installing resharper ;-)
Marc Wittke
+2  A: 

Check the specification:

Any method from any accessible class or struct that matches the delegate's signature, which consists of the return type and parameters, can be assigned to the delegate.

bja