C# Way to See How Many Methods are Subscribed to Event

I was wondering if it was possible to see how many methods, or how many times an event has been subscribed through, either by checking inside the event’s class, or outside the class?

Example code:

//Example code that subscribes to event
public void AddEvents()
{
	EventManager.SuccessfulEvent += OnSucceeded;
	EventManager.FailedEvent += OnFailed;
	EventManager.CancelledEvent += OnCanceled;
}

public void CheckHowManySubscriptions()
{
	//Pseudo code, b/c I'm not sure what to do
	//This code would tell me that one method has been
	//subscribed to Successful Event
	HowMany(EventManager.SuccessfulEvent);

}

That wasn’t a very focused answer.

If it’s an event, then you can’t use that outside of the class, but you could of course return the length of it in a public property in the class that raises the event.

1 Like