I have the following problem:
I got a class with ~100 static events and i want to set all those events to null (removing all delegates) when Disposing.
Can I do this using reflection? because otherwise it would be a lot to write and hard to keep in sync with changes.
I tried something like this:
foreach (EventInfo eventInfo in GetType().GetEvents(BindingFlags.Static | BindingFlags.Public))
{
// ?
}
but i dont know how to set them null. I guess this is not workong with reflection, is their maybee another easy way?
Br,
David
The following ought to work:
Provided that there are indeed backing fields for the events of course, otherwise there is no way to “set” them.