我需要获取基类型对象的类型。但是我不能使用BaseType,因为我不知道对象有多少级别的类型。在不知道派生类型的情况下检索基类型
class Base
{
public string Name { get set; }
public DoAThing()
{
Type myType = GetType(); // returns Derived
}
}
class Derived : Base
{
public int Age { get; set; }
public void DoSomething()
{
DoAThing();
}
}
是否有可能在的myType基地类型?
休息一下,明天再看吧:) – 2010-09-01 01:27:59
现在,我知道,如何做到这一点,但无论如何,我会采取休息:) – mnn 2010-09-01 01:30:23