I have an object, I would like to print out all its parent type up to the Object? How to do that?
If you're only interested in the class hierarchy:
Type type = obj.GetType();
while (type != null)
{
Console.WriteLine(type.Name);
type = type.BaseType;
}
var t = obj.GetType();
while (t != null)
{
Console.WriteLine(t.Name);
t = t.BaseType;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With