c# - How to find types that are direct descendants of a base class? -
i need types of assembly inherits base class first descendants. instance if have:
class base { } class firstclass : base { } class secondclass : firstclass { }
now
var directones = assembly.gettypes().where(t => t.issubclassof(typeof(base)));
should return firstclass
, not secondclass
. there way find out?
instead of issubclassof()
can use type.basetype
e.g.
var directones = assembly.gettypes().where(t => t.basetype == (typeof(base)));
(fyi: don't think there's way find interfaces type directly implements.)
Comments
Post a Comment