Get derived class type from a base's class static method
- by Marco Bettiolo
Hi,
i would like to get the type of the derived class from a static method of its base class.
How can this be accomplished?
Thanks!
class BaseClass {
static void Ping () {
Type t = this.GetType(); // should be DerivedClass, but it is not possible with a static method
}
}
class DerivedClass : BaseClass {}
// somewhere in the code
DerivedClass.Ping();