I'm using a Dictionary<TKey, TValue>
and I'm getting some odd, though somewhat understandable behaviour in my tests.
No matter the order I add entries to the dictionary when I call Dictionary.Keys
the keys are returned in the order specified by the IComparable<T>
implementation for the key's type.
This is good for me as I want to get them in that order anyway, but I can't find anywhere that specifies that they should and will always be returned this way. Therefore, I don't know whether to rely on it always being like that or doing a (potentially redundant) sort on the List<T>
I'm building.
Can I rely on this behaviour or not?