A Guided Garden Stroll through the .NET Framework Class Library

Namespace: SYSTEM.COLLECTIONS and
SYSTEM.COLLECTIONS.SPECIALIZED

● I am the COLLECTIONS* Namespace. I am useful any time you want to work with a group of objects.

In application development, my most popular classes are the ArrayList*, which is typically used as a place to stuff a series of "like objects" into, and Hashtable*, which is similar to ArrayList, but allows one to quickly retrieve objects out of the collection by supplying a key string or number.

Another useful class is the SortedList*. Use SortedList when you need to access a collection of objects both by key and by relative index number. When you add a new object to a SortedList it appears in the list in order sorted by the key value you supply. You can also control the sorting rules I use via the IComparer* interface.

A really useful feature of the ArrayList, Hashtable, and SortedList collections (and others) is that you can iterate through all of your objects that you put in the collection using the Visual Basic.NET and C# "for each"* language construct.

One thing to remember, however, is that when using "for each", both Hashtable and SortedList returns both your key and your object in a single element called a DictionaryEntry, so does not return your object directly as you might first expect.

I also contain a Stack and Queue class which allows for "last-in first-out" and "first-in first-out" grouping of your objects via Push and Pop and Enqueue and Dequeue methods.

Some of my interfaces that you should find extremely useful are the IEnumerable* and IEnumerator*. These very simple interfaces allow you to use encapsulation instead of the overly used inheritance mechanism for enabling the ever popular "for each" language construct and strong typing on your custom business collections.

Often your application will need a collection of strings tied to a key for information lookups. Use my System.Collections.Specialized namespace with NameValueCollection, StringCollection, and StringDictionary classes any time you need a collection of strings.

And if you need your Hashtable or SortedList collections to have case insensitive keys, use my Specialized.CollectionsUtil class to create them.

www.Orbonyx.com