Arsen Zahray
Arsen Zahray

Reputation: 25287

How to enumerate all events which a class declares?

I would like to be able to enumerate all events, which a class implements.

class A
{
    public delegate void X();
    public event X EventA;
}

class B:A
{
    public event X EventB;
}

What should I do to typeof(B) to get a list, which would consist of EventB?

Upvotes: 2

Views: 208

Answers (1)

zmbq
zmbq

Reputation: 39013

Well, there's the Type.GetEvents method, you should use it. If you only want events declared at B, and not inherited from A, pass DeclaredOnly as one of the binding flags.

Upvotes: 6

Related Questions