Does assigning null remove all event handlers from an object?

.net, c#, com, delegates, event-handling

Solution

yes, you should use overloaded `-=` to unsubscribe an event.

simply assigning a reference to `null` will not do that automatically. The object will still be listening to that event.

Problem

I have defined new member in my class ``` protected COMObject.Call call_ = null; ``` This class has the following event handler that I subscribed to ``` call_.Destructed += new COMObject.DestructedEventHandler(CallDestructedEvent); ``` Will setting my member to null as following remove the event handler? ``` call_ = null; ``` or I have to unsubscribed with -=?

Original source