In the MSDN Events Tutorial hooking up to events is demonstrated with the example:
// Add "ListChanged" to the Changed event on "List":
List.Changed += new ChangedEventHandler(ListChanged);
...
// Detach the event and delete the list:
List.Changed -= new ChangedEventHandler(ListChanged);
Where as I have been keeping a reference to the delegate. Example:
ChangedEventHandler myChangedEvent = new ChangedEventHandler(ListChanged);
List.Changed += myChangedEvent;
...
List.Changed -= myChangedEvent;
When I look at the MSDN example code, "-= new" just looks wrong to me. Why would this List have a reference to an event handler I just created?
Obviously I must be thinking about things the wrong way? Can I get a pointer to a technical explanation of how -= works, seeing how -= appears to not be using one.