开发者

Are these Startup event handlers identical?

开发者 https://www.devze.com 2023-01-12 06:28 出处:网络
I\'m working on a Silverlight project and I\'m trying to understand the differences between the following:

I'm working on a Silverlight project and I'm trying to understand the differences between the following:

this.Startup += new StartupEventHandler(this.Application_Startup);
this开发者_Go百科.Startup += this.Application_Startup;


These are identical. The difference is just syntactic sugar: the compiler is automatically wrapping the function in a delegate in the second case.

This has been around since .NET 2.0; prior to that only the first case would have compiled.


These are the same, the second line is a little syntax sugar - the compiler will wrap Application_Startup method into the delegate StartupEventHandler automatically.

0

精彩评论

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

关注公众号