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

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

    Up to a certain list size it is cheaper to just check every entry instead of hashing. That is probably what is happening.

    Add 100 or 1000 items and see if they are still in the same order.

提交回复
热议问题