How do I return the type of an interface without mentioning the name of the derived class?

I am looking for a way not to reference the class name but still achieve the desired effect. I cannot do ITypedList.GetType () because it is an interface.

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

      

I am wondering if this is possible.

Cheers,
edit: Trying to replace this with one that doesn't mention its own class name

+1


a source to share


2 answers


Absolutely...



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

      

+4


a source


Just call GetType

on the current instance:



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

      

0


a source







All Articles