Sorting Hashtable by Order in Which It Was Created
This is similar to How to keep the order of elements in hashtable , except for .NET. Is there any Hashtable or Dictionary in .NET that allows you to access it's .Index property for the entry in the order in which it was added to the collection? A NameValueCollection can retrieve elements by index (but you cannot ask for the index of a specific key or element). So, var coll = new NameValueCollection(); coll.Add("Z", "1"); coll.Add("A", "2"); Console.WriteLine("{0} = {1}", coll.GetKey(0), coll[0]); // prints "Z = 1" However, it behaves oddly (compared to an IDictionary) when you add a key