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.
精彩评论