views:

166

answers:

2

Hi all, I'm looking for a way to not reference the class name, yet still achieve the desired effect. I can't do ITypedList.GetType() because it is an Interface.

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

I'm wondering if this is possible.

Cheers,
edit: Trying to replace this with something that doesn't mention it's own class name

+4  A: 

Absolutely ...

    public PropertyDescriptorCollection GetItemProperties()
    {
        return TypeDescriptor.GetProperties(this);  
    }
JP Alioto
A: 

Just call GetType on the current instance:

return TypeDescriptor.GetProperties(this.GetType());
Guffa