All I want to do is similar to:
public abstract class BaseClass
{
public static Type GetType()
{
return typeof(BaseClass);
}
}
But when I derive it
public class DerivedClass : BaseClass
{
}
I want to get
Assert.AreEqual(typeof(DerivedClass), DerivedClass.GetType());
How to change the BaseClass to make this assertion true?
Static methods are not inherited.
The compiler substitutes
BaseClassforDerivedClasswhen calling a base class’ static methods through one of its derived classes. For example, here’s the IL code for a call toDerivedClass.GetType():