Search code examples
c#reflectionobjectbrowser

Get BaseTypes of an Assembly by Reflection


im trying to develop an app. like vs ObjectBrowser and flow was something like this: stackoverflow.com/questions/6939400/create-a-application-like-visual-studio-object-browser

now my problem was i cant find the method for calling all basetypes ... something like: enter image description here

instead i can only see "Object" as BaseType for Class ...

Q: Is there a way I can get all basetypes via reflection?

Solution

  • Interfaces (IComparable, IStructuralComparable etc.) are not base types, since a base type can be only one (Object in your case). If you want to get all the interfaces implemented use

      Type tp = ... // type of interest
    
      Type baseType = tp.BaseType; // Base type
      Type[] interfaces = tp.GetInterfaces(); // Interfaces