Get Child classes from base class

You can do this:

var subclassTypes = Assembly
   .GetAssembly(typeof(BaseClass))
   .GetTypes()
   .Where(t => t.IsSubclassOf(typeof(BaseClass)));

you can select the Assembly you want to check, get the types with the method Assembly.GetTypes() and test for each of them if it is a subclass with Type.IsSubclassOf()

see Assembly members and Type members


Not directly, however you can use AppDomain.GetAssemblies() to get all the currently loaded assemblies, and then use Assembly.GetTypes() to get all the types in that assembly. Then use Type.IsSubclassOf() to determine if it's a subclass of the type you're after.

Tags:

C#

Class