开发者

Are these Startup event handlers identical?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜