Possible Duplicate:
Attaching Eventhandler with New Handler vs Directly assigning it
I noticed there are two possible way to add an event listener:
List.Changed += new ChangedEventHandler(ListChanged);
or simply,
List.Changed += ListChanged;
What is the difference between these two declaration?
The autocomplete in Visual Studio generates the former, but I wonder whether they have different behaviour. Beside, if we use the former, how do we remove the listener? If we use the latter, List.Changed -= ListChanged; will work, right?
Both will generate the same IL, so there is no difference. In the shorter example, the compiler automatically infers the delegate type to be used.
Removing the listener is equally interchangable: