I wrote a small method to list the inherited types but it doesn't works with a TreeNode
for example:
Assume this classes:
class B { }
class A : B { }
class C :TreeNode { }
And then:
GetInheritedTypes(typeof(A)); //typeof(B)
GetInheritedTypes(typeof(C)); // 0 items
The method to list them:
List<Type> GetInheritedTypes(Type baseType)
{
return Assembly.GetAssembly(baseType)
.GetTypes()
.Where(type => type != baseType && type.IsAssignableFrom(baseType))
.ToList();
}
Why is GetInheritedTypes(typeof(C))
returning 0 items instead of Typeof(TreeNode)
?
Aucun commentaire:
Enregistrer un commentaire