.GetType().GetProperties() returns properties in different order

后端 未结 1 1989
生来不讨喜
生来不讨喜 2020-12-22 01:45

I want to check our configuration file and see if it is the same as if I were to create a new configuration file. This method is called GetConfig().

After some hours

相关标签:
1条回答
  • 2020-12-22 01:52

    You cannot make any assumption about the order of return values of Type.GetProperties, see what documentation says:

    The GetProperties method does not return properties in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which properties are returned, because that order varies.

    If you want an specific order, you should make your code order the collection returned.

    0 讨论(0)
提交回复
热议问题