开发者

Binding event without eventhandler..why it works?

开发者 https://www.devze.com 2022-12-10 17:54 出处:网络
I simpl开发者_Go百科y do not understand why both works: this.timer.Tick += new EventHandler(timer_Tick);

I simpl开发者_Go百科y do not understand why both works:

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

Thanks


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.


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.

0

精彩评论

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