axnst2
asked on
Get a list of all of a class's base types recursively
HI Experts,
The title says it all: How do I get a list of all of a class's base types recursively.
So if I have this:
interface A
{ }
class B : A
{ }
class C : B
{ }
I would like a list containing A, B, and C.
I could do it using reflection and recursively get object.BaseType.Name over and over again, but is there anything else built into the framework?
Thanks!
The title says it all: How do I get a list of all of a class's base types recursively.
So if I have this:
interface A
{ }
class B : A
{ }
class C : B
{ }
I would like a list containing A, B, and C.
I could do it using reflection and recursively get object.BaseType.Name over and over again, but is there anything else built into the framework?
Thanks!
ASKER
Ok, I'm not worried about interfaces, but how would reflection give me the names of all of a Type's base types without putting BaseType.Name into a recursive function of somekind.
Otherwise, i would get a list of ALL Types in the assmbly even if they are not related to each other what so ever...
Otherwise, i would get a list of ALL Types in the assmbly even if they are not related to each other what so ever...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As I stated in my original post, I know I have a way of obtaining the info by using a recursive function, I was just hoping I guess that there was a better way of doing it.
ASKER
Thanks!
To get the base classes, yes, you can use reflection. It doesn't need to be recursive, though.