Order when iterating over an dictionary
本问题已经有最佳答案,请猛点这里访问。
在C中迭代字典时,我们是否保证每次迭代该字典时顺序都相同?
1 2 3 4 | foreach (var key in myDict.Keys) { ... } |
根据文件,不,不保证:
The order of the keys in the
Dictionary is unspecified,but it is the same order as the associated values in the.KeyCollection Dictionary returned by the Values property..ValueCollection
号