Everyone is pointing you at a Hashtable, but that is NOT the only solution. If
your collection is small, then you can do your own linear search through the
elements. If your collection is sorted, then you can use BinarySearch with
a custom comparer.
Your options are determined base on your data. If you have plenty of elements
then definitely go to a Hashtable, it will be faster.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog:
http://weblogs.asp.net/justin_rogers
"Jack Addington" <ja********@shaw.ca> wrote in message
news:Od**************@TK2MSFTNGP14.phx.gbl...
How do I go about accessing elements of an Arraylist using something other
than the index?
I have a class that manages a number of subclasses. Those subclasses are
stored in an arraylist. The subclass has a key property that is a string. I
would like to be able to call Class1.SubClassManager[string key] as opposed
to Class1.SubClassManager[int index].
I tried overriding ArrayList but then I wasn't sure what method to then
override or if there was a simpler method.
thanks
jack