문제

After Getting a System.Reflection.PropertInfo array for a class- Does anyone know how or if this array is sorted or do I have to Array.Sort(MySortMethods/Params)?

도움이 되었습니까?

해결책

Presumably you're getiing the PropertyInfo array by calling GetProperties, in which case the ordering of the array isn't guaranteed.

From the MSDN documentation:

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.

다른 팁

I would check the documentation for the method you're using to get the PropertyInfos. If it doesn't state anything about the ordering of results I would assume they are not ordered and order them myself as you suggest.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top