Reputation: 13121
I don't understand what the difference between these 2 variations are. What is the pros/cons of each approach?
1. a.MyEvent += new MyClass.MyEventDelegate(FireEvent);
2. a.MyEvent += FireEvent;
Upvotes: 5
Views: 101
Reputation: 82335
Really it's syntactical sugar, the compiler will interpret the code and make the Delegates for you.
Upvotes: 2
Reputation: 421988
The first one works in all versions of C# while the second only works on 2.0 and above. If you need your to compile you code with C# 1.0 compiler, go with the first one; otherwise, I'd use the more concise version. The generated code should be identical in both cases.
Upvotes: 6