Q:

HashTable to Dictionary conversion

I have converted a hashtable into dictionary. but the problem is when I go to print the values it does not show in sequencing order. 
aHashtable.Add(1014, "201");
aHashtable.Add(10, "ATIB");
aHashtable.Add(143, "LOVE");
aHashtable.Add(111, "HATE");

var dict= aHashtable.Cast<DictionaryEntry>().ToDictionary(d => d.Key, d => d.Value);

foreach (KeyValuePair<object, object> keyValuePair in dict)
{
    Console.WriteLine(keyValuePair.Key + ": " +keyValuePair.Value);
}

What's the problem?

A:

By default a dictionary is not sorted. C# has a OrderedDictionary though.
See also: The order of elements in Dictionary

