问题
Is there a difference between these two formats for subscribing to events:
Style 1:
foo.BarEvent += FooEventMethod;
Style 2:
foo.BarEvent += new FooEventHandler(FooEventMethod);
回答1:
This is c# 1.0 style of subscribing an event.
foo.BarEvent += new FooEventHandler(FooEventMethod);
Starting from c# 2.0 you're allowed to subscribe event like this
foo.BarEvent += FooEventMethod;
above code is exactly equal to version1 code, what happens is compiler will create new FooEventHandler(FooEventMethod) in background for you.
来源:https://stackoverflow.com/questions/23708421/difference-in-event-subscription-formatting