StriplingWarrior
StriplingWarrior

Reputation: 156614

How can I examine the inheritance hierarchy of my c# application at runtime?

Given a class like this:

public class A : B<C> {...}

Assume that I know how to find A's class type using reflection. How can I figure out at run time what base class it extends (in this case B)?

Upvotes: 0

Views: 126

Answers (1)

ChaosPandion
ChaosPandion

Reputation: 78282

You can do something like this.

var a = new A();

Console.WriteLine(a.GetType().BaseType);

Upvotes: 4

Related Questions