`Type.GetProperties` property order

后端 未结 5 1925
一生所求
一生所求 2020-12-09 16:13

Short Version

The MSDN documentation for Type.GetProperties states that the collection it returns is not guaranteed to be in alphabetical or declara

5条回答
  •  执念已碎
    2020-12-09 16:35

    For what it's worth, sorting by MetadataToken seemed to work for me.

    GetType().GetProperties().OrderBy(x => x.MetadataToken)
    

    Original Article (broken link, just listed here for attribution): http://www.sebastienmahe.com/v3/seb.blog/2010/03/08/c-reflection-getproperties-kept-in-declaration-order/

提交回复
热议问题