Lets say we have a delegate
public delegate void MyEventHandler(string x);
and an event handler
public event MyEventHandler Something;
we add multiple events..
for(int x = 0; x <10; x++)
{
this.Something += HandleSomething;
}
My question is .. how would one remove all methods from the eventhandler presuming one doesn't know its been added 10 (or more or less) times?
Simply set the event to
null
:It will unregister all event handlers.
As pseudo idea:
C#5 <
Usage:
C#6
Usage: