Iterating over class properties

前端 未结 2 1497
囚心锁ツ
囚心锁ツ 2020-12-16 13:16

I\'m trying to iterate over the Color class\' Color properties.

Unfortunately its not in a collection so its just a class with a bunch of static properties.

2条回答
  •  悲哀的现实
    2020-12-16 14:20

    You might also be interested in this code

    http://blog.guymahieu.com/2006/07/11/deep-reflection-of-properties-propertyreflector/

    It provides an easy way to set/get properties by name. If you look into GetBestMatchingProperty you'll find the iteration over properties, that is done the same way as been posted before Iterating over class properties

提交回复
热议问题