By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,935 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

Getting list of Properties using Reflection

P: n/a
Hi,

I'm trying to get a list of properties from a hierarchy of classes,
using reflection.

Using Type.GetProperties(), I get the list back in "reverse hierarchy
order" (derived class properties before parent class properties)

Using TypeDescriptor.GetProperties(), the order of the returned
properties is also wrong.

I used the XmlSerializer to test my classes, and the properties was
written out correctly (Parent class before derived class).

What can I do to get a list of properties in the correct order (Parent
class before inherited class)?

Thanks for the help,
Dawid Mostert
d_*******@nospam.hotmail.com
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
What can I do to get a list of properties in the correct order (Parent
class before inherited class)?


Get only the properties that are declared in the class itself (specify
BindingFlags.DeclaredOnly), and manually walk the inheritance
hierarchy.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2

P: n/a
Thanks!

Sounds like a good idea... Any other (less manual ;) ) options?

How do I combine 2 arrays into 1?

Regards,
Dawid

Mattias Sjögren wrote:
What can I do to get a list of properties in the correct order (Parent
class before inherited class)?

Get only the properties that are declared in the class itself (specify
BindingFlags.DeclaredOnly), and manually walk the inheritance
hierarchy.

Mattias

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.