OriginalGriff has made a nice and small class. But I don't think I would use this code in an application. Most times when I want to know about the inheritance chain of an object is while I'm coding. So a quick and nice (commandline?) tool would be a better fit, I think. The problem with OriginalGriff's solution is that I always have to reference the assembly containing the type. So if I create a tool and then use the "
" class, I will have to add a reference to the assembly containing the type, otherwise it would be impossible to call the constructor.
To avoid this problem, I created a (very quick ;) ) commandline tool based on the parsing capability of the
static void Main(string args)
if (args.Length > 0)
Type typeWithUnknownInheritanceChain = Type.GetType(args);
if (typeWithUnknownInheritanceChain != null)
List<Type> listTypes = GetInheritanceChain(typeWithUnknownInheritanceChain);
foreach (Type type in listTypes)
static List<Type> GetInheritanceChain(Type type)
List<Type> listTypes = new List<Type>();
while (type != null)
type = type.BaseType;
static void ShowHelp()
Console.WriteLine("Syntax: InheritanceChain TypeName");
Console.WriteLine("TypeName\tInheritanceChain see MSDN Help about Type.GetType(String) Method for possible TypeName strings");
Console.WriteLine("Example: InheritanceChain \"System.Windows.Forms.Form,System.Windows.Forms,Version=220.127.116.11,Culture=neutral,PublicKeyToken=b77a5c561934e089\"");
But most times when I work with Visual Studio, I just use the object browser to find out about the inheritance chain.