Will GetType () return the most derived type when called from the base class?
Example:
public abstract class A { private Type GetInfo() { return System.Attribute.GetCustomAttributes(this.GetType()); } } public class B : A {
Or do I just need to make an abstract method that derived classes will have to implement as follows?
public abstract class A { protected abstract Type GetSubType(); private Type GetInfo() { return System.Attribute.GetCustomAttributes(GetSubType()); } } public class B : A {
inheritance polymorphism c #
Feisty Mango Apr 25 2018-11-11T00: 00Z
source share