Why are entries in addition order in a .Net Dictionary?

前端 未结 11 596
死守一世寂寞
死守一世寂寞 2020-12-04 01:26

I just saw this behaviour and I\'m a bit surprised by it...

If I add 3 or 4 elements to a Dictionary, and then do a \"For Each\" to get all the keys, they appear in

11条回答
  •  不思量自难忘°
    2020-12-04 02:08

    A quote from MSDN :

    The order of the keys in the Dictionary<(Of <(TKey, TValue>)>).KeyCollection is unspecified, but it is the same order as the associated values in the Dictionary<(Of <(TKey, TValue>)>).ValueCollection returned by the Dictionary<(Of <(TKey, TValue>)>).Values property.

提交回复
热议问题