这些Startup事件处理程序是否相同?

6 c# silverlight

我正在开发Silverlight项目,我正在尝试理解以下内容之间的差异:

this.Startup += new StartupEventHandler(this.Application_Startup);
this.Startup += this.Application_Startup;
Run Code Online (Sandbox Code Playgroud)

Dan*_*haw 3

这些是相同的。区别只是语法糖:在第二种情况下,编译器会自动将函数包装在委托中。

自 .NET 2.0 以来,这一点就已存在;在此之前,只有第一个案例可以编译。