Undocumented feature of Dictionary?

Posted by Jon on Stack Overflow See other posts from Stack Overflow or by Jon
Published on 2010-05-11T10:38:58Z Indexed on 2010/05/11 10:44 UTC
Read the original article Hit count: 190

Filed under:
|
|
|
Dictionary<string, int> testdic = new Dictionary<string, int>();
testdic.Add("cat", 1);
testdic.Add("dog", 2);
testdic.Add("rat", 3);
testdic.Remove("cat");
testdic.Add("bob", 4);

Fill the dictionary and then remove the first element. Then add a new element. Bob then appears at position 1 instead of at the end, therefore it seems to remember removed entries and re-uses that memory space?

Is this documented anywhere because I can't see it on MSDN and has caused me a day of grief because I assumed it would just keep adding to the end.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET