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

前端 未结 11 624
死守一世寂寞
死守一世寂寞 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:10

    Your entries might all be in the same hash bucket in the dictionary. Each bucket is probably a list of entries in the bucket. This would explain the entries coming back in order.

提交回复
热议问题