Try a SortedDictionary instead of Dictionary. (If you really want to iterate the items in ascending order, not only for debugging).
I do not think that it is a defect.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
This code was compiled with .NET Core 6, I couldn't find anything about this "logic" to add my dictionary object new key pair at some point as the first element.
I uploaded the video here https://1drv.ms/v/s!AoltFOAIRGjJr-pvSk4kEm2F77zlow?e=RRCoBw , it happens at second 19.
Is this a strange bug in the SDK? Or is there a logic to it?
With kind regards
Nghia Cheng
Try a SortedDictionary instead of Dictionary. (If you really want to iterate the items in ascending order, not only for debugging).
I do not think that it is a defect.
the dictionary is implemented as a hash table, so no order is present. if you want a fifo then use a queue. you may want to create a custom class, that stores the items in a hash table, but also keeps a lists for both key lookup and fifo.
note: many of the collection use a special case for low number of entries, because looping thru a list is faster than key lookup for small number of compares.