locked
How to get derived class properties alone ?..... RRS feed

  • Question

  • Hi All,

    I am using reflection to get properties.

    I am getting Base Class Properties + Derived Class Properties.

    Is there any way to get derived class properties alone.(I dont want base class properties.)

    Help me.

    Thanks in advance.

          PropertyInfo[] property = objectType.GetProperties();
          PropertyInfo[] propertyBase = objectType.BaseType.GetProperties();

    Thanks and Regards,

    Arul prakash.M

    Wednesday, July 7, 2010 9:25 AM

Answers

  • use this snip

    PropertyInfo[] propNames = typeof(Derived1).GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance);

    Hope this helps...

     

    Wednesday, July 7, 2010 10:34 AM