2009-05-22 59 views
1

我正在寻找一种方式来而不是引用类名称,但仍然达到预期的效果。 我不能做ITypedList.GetType(),因为它是一个接口。如何在不提及派生类名的情况下返回接口类型?

public class DerivedList : ITypedList 
... 
public PropertyDescriptorCollection GetItemProperties() 
{ 
    return TypeDescriptor.GetProperties(typeof(DerivedList)); 
} 
... 

我想知道这是否可能。

干杯,
编辑:尝试的东西,并没有提到它自己的类名

+0

我觉得这个问题有点不清楚,但它可能只是我。你想要替换这行'返回TypeDescriptor.GetProperties(typeof(DerivedList));'有没有提到它是自己的类名? – Jiminy 2009-05-22 02:05:13

回答

4

绝对替换此...

public PropertyDescriptorCollection GetItemProperties() 
    { 
     return TypeDescriptor.GetProperties(this); 
    } 
0

就叫GetType在当前实例:

return TypeDescriptor.GetProperties(this.GetType()); 
相关问题