Export (0) Print
Expand All

Generic Collection Types

Generic collections are the common variations of data collections, such as hash tables, queues, stacks, dictionaries, and lists.

Collections are based on the ICollection interface, the IList interface, or the IDictionary interface. The IList interface and the IDictionary interface are both derived from the ICollection interface; therefore, all collections are based on the ICollection interface either directly or indirectly. In collections based on the IList interface or directly on the ICollection interface (such as Array, ArrayList, Queue, or Stack), every element contains only a value. In collections based on the IDictionary interface (such as Hashtable or SortedList), every element contains both a key and a value.

The Collections namespace includes base collections, such as CollectionBase, ReadOnlyCollectionBase, and DictionaryBase, which are abstract base classes that can be extended to create collection classes that are strongly typed.

Collections can vary, depending on how the elements are stored, how they are sorted, how searches are performed, and how comparisons are made. A Queue is a first-in-first-out list, while a Stack is a last-in-first-out list. A SortedList is a sorted version of a Hashtable. Elements in a Hashtable are accessible only by the key of the element, but elements in a SortedList are accessible either by the key or by the index of the element. The indexes in all collections, except Array, are zero-based.

See Also

Grouping Data in Collections | System.Collections Namespace | ICollection | IList | IDictionary

© 2014 Microsoft