Get derived class type from a base's class static method
Posted
by Marco Bettiolo
on Stack Overflow
See other posts from Stack Overflow
or by Marco Bettiolo
Published on 2010-06-17T17:55:22Z
Indexed on
2010/06/17
18:13 UTC
Read the original article
Hit count: 175
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();
© Stack Overflow or respective owner