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

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

    From what I know this shouldn't be a behavior to rely on. To check it quickly use the same elements and change the order in which you add them to the dictionary. You'll see if you get them back in the order they were added, or it was just a coincidence.

提交回复
热议问题