正在调用 ToArray()
/ToList()
在 SortedSet<T>
保证返回排序的数组/列表?
当我调用这些方法中的任何一个时,我确实得到了一个排序的集合。然而,the documentation似乎没有提到这种行为。它的开场白是:
Represents a collection of objects that is maintained in sorted order.
但我不确定这是否隐含地保证了这种行为。
假设这是有保证的行为是否安全?或者转换为数组/列表后的顺序实际上是未定义的,完全取决于实现的常识?
最佳答案
是的,如 docs 中所述
An enumerator that iterates through the SortedSet in sorted order.
关于c# - 在 SortedSet<T> 上调用 ToArray()/ToList() 是否保证返回排序的数组/列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44117327/