Using GetProperties() with BindingFlags.DeclaredOnly in .NET Reflection

Viewed 35733

If I use

sometype.GetProperties();

I get all of the properties from the type and it's parent. However I only want to retrieve the properties defined explicitly in this type (not the parents). I thought that was what the BindingFlags.DeclaredOnly option was for.

However, when I try this:

sometype.GetProperties(BindingFlags.DeclaredOnly);

I get 0 properties.

Anyone know what I am doing wrong?

5 Answers
Related