Chapter 5. Collections
5.0. Introduction
Collections are groups of items; in .NET, collections contain objects, and each object contained in a collection is called an element. Some collections contain a straight-forward list of elements, while others (dictionaries) contain a list of key and value pairs. The following collection types consist of a straightforward list of elements:
System.Collections.ArrayList System.Collections.BitArray System.Collections.Queue System.Collections.Stack System.Collections.Generic.LinkedList<T> System.Collections.Generic.List<T> System.Collections.Generic.Queue<T> System.Collections.Generic.Stack<T> System.Collections.Generic.HashSet<T>
The following collection types are dictionaries:
System.Collections.Hashtable System.Collections.SortedList System.Collections.Generic.Dictionary<T,U> System.Collections.Generic.SortedList<T,U>
The following collection type is a new addition to the .NET Framework Class Library (FCL), which can be thought of as a list of elements with no duplicates:
System.Collections.Generic.HashSet<T>
These collection classes are organized under the System.Collections and the System. Collections.Generic namespaces. In addition to these namespaces, another name-space called System.Collections.Specialized contains a few more useful collection classes. These classes might not be as well known as the previous classes, so here is a short explanation of the collection classes under the System.Collections.Specialized namespace:
ListDictionary ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access