1

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?
Community
  • 1
  • 1
Elegiac
  • 361
  • 2
  • 15
  • By "base types" you mean types, not presented in assembly or types from mscorlib? Anyway, you can get all types from assembly, then for each type take all their base types. which are not presented in assembly... – Alex Voskresenskiy Jan 27 '15 at 14:17
  • Reflection is nice for objects your application needs and loads naturally. If you want to analyze independent assemblies, I strongly recommend using something else, like Mono.Cecil. Don't try to use reflection-only loading. – CodesInChaos Jan 27 '15 at 14:46

1 Answers1

2

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
Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215