YIf what you need is a data structure that allows both direct and sequential access to its elements, you can use a SortedList.
This type is kept ordered by a key, allowing you sequentially access all of its elements and implements the IDictionary interface, allowing direct access to a specific key/value pair. Here you have some code example: using System; using System.Collections; namespace ConvertSamples { class myApp { static void Main() { SortedList sl = new SortedList(); // Fill some spots with sl[Key] = Value sl["Hello"] = 1; sl["World"] = 55; sl["alo"] = 23; sl["Boo"] = 1927; sl["Foo"] = 1321; // Direct access using the Key Console.WriteLine("Direct Access: Key=Hello, Value={0}", sl["Hello"]); Console.WriteLine("Direct Access: Key=World, Value={0}", sl["World"]); // Sequential access to all elements, ordered by Key foreach (DictionaryEntry item in sl) Console.WriteLine("Sequential Access: Key= {0}, Value= {1}", item.Key, item.Value); } } } Federico Raggi Latam Developers Initiative Manager Microsoft Phone: (954)489-4862 Mobile: (954)465-4862 > -----Original Message----- > From: Brad Wilson [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 23, 2002 11:40 AM > To: [EMAIL PROTECTED] > Subject: Re: [DOTNET] Hashtables and structs > > Greg Gates wrote: > > > 2) What is the most efficent way to sort and filter a hashtable in .NET. > > Hash tables are not stored in any ordered fashion. Retrieval will appear > to > be random based on the hash algorithm used. Of course, you can retrieve > all > the items and use your own sorting system as necessary. > > If you need a collection that stays ordered (by key, generally), you > should > be looking for something more like a tree than a hash table. Nothing like > that ships with .NET that I'm aware of... > > Brad > > -- > Read my web log at http://www.quality.nu/dotnetguy/ > > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.