简体   繁体   中英

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.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.

这些都是一样的,第二行是一点点语法糖 - 编译器会自动将Application_Startup方法包装到委托StartupEventHandler中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM