How can I get the name of the parent class of some class using Reflection?
How can I get the name of the parent class of some class using Reflection?
I would like to add some more details, in case you need to find the ultimate parent class of your class, this code could help. I consider that I don't know whether the type is a class or an interface.
do
{
if (type.IsInterface)
if (type.BaseType == null)
break;
if (type.IsClass)
if (type.BaseType == typeof(object))
break;
type = type.BaseType;
} while (true);
string ultimateBaseTypeName = type.Name;