Getting System.Type from static method
Is it possible to get the System.Type of a subclass from a static method in an abstract class?
public abstract class MyBase
{
public static void MyMethod()
{
//Get System.Type here?
}
}public class MyDerived: MyBase
{
}
When I call
MyDerived.MyMethod();
Is it then possible to get the type of MyDerived in the method MyMethod()?
Thanks
Brian
No, this is not possible. Although the C# compiler allows you to call MyMethod via the MyDerived class, underneath, the method is actually being called via MyBase.
The only way you can do this, is to make MyMethod a instance method.