Is there a method or technique that allows you to insert an element into a
Dictionary
guaranteeing that the item is in the first index of t
Dictionaries are unordered; elements are meant to be retrieved with a key, whose hash points to its value's location.
What you might want is a List
, whose elements can be inserted into a specific index.
List> list = dic.ToList();
list.Insert(0, new KeyValuePair("a", "b"));
foreach(KeyValuePair pair in list)
Console.WriteLine("{0} = {1}", pair.Key, pair.Value);