Is it possible in C# to get types of subclasses from base class?
If you're trying to get the base class name, it'd be something like: Type classType = typeof(YourClass); Type baseType = classType. BaseType; string baseClassName = baseType.Name; Note that, if you recursively search the base types, when you call BaseType on typeof(System.
The reference holding the child class object reference will not be able to access the members (functions or variables) of the child class. This is because the parent reference variable can only access fields that are in the parent class.
Multiple Inheritance is a feature of an object-oriented concept, where a class can inherit properties of more than one parent class. The problem occurs when there exist methods with the same signature in both the superclasses and subclass.
Hierarchies. Multiple classes can be derived from a single parent. There is no limit to the number of children a class can have (but a child can have only one parent).
You can do this:
var subclassTypes = Assembly .GetAssembly(typeof(BaseClass)) .GetTypes() .Where(t => t.IsSubclassOf(typeof(BaseClass)));
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