Is it possible to sort a HashTable?

前端 未结 11 724
不知归路
不知归路 2021-01-17 10:13

I have a property that returns a HashTable. I would like to sort it without refactoring my property. Please note: I do not want to return another type.

11条回答
  •  生来不讨喜
    2021-01-17 11:05

    lubos is right: you can't sort a HashTable. If you could, it wouldn't be a HashTable. You can enumerate the HashTable, and then sort the enumeration. But that would be very slow. Much better to use a SortedDictionary instead.

提交回复
热议问题