Order reflection requests in dotnet

When I call GetProperties () on a type, the properties are ordered as they are written in the source code. This is very convenient, but my question is whether this is a guaranteed behavior or may be changed depending on the version of the execution and the environment. Does anyone know something about this?

+3
source share
1 answer

No, you cannot assume that the order will remain the same.

Quote from the doc :

The GetProperties method does not return properties in a specific order, for example, in alphabetical order or in declaration order. Your code should not depend on the order of returning the properties, since this order is changing.

+6
source

Source: https://habr.com/ru/post/1337736/


All Articles