System.Collections

.NET Core API Documentation

Namespace: System.Collections

Overview

The System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, arrays, hash tables, and dictionaries. These collections are fundamental building blocks for managing groups of related objects in .NET applications.

While the generic collection types in System.Collections.Generic are generally preferred for type safety and performance, the non-generic collections remain relevant for compatibility and certain scenarios.

Key Interfaces

IEnumerable

Supports iteration over a collection of a type that does not use generics.

ICollection

Represents a collection of objects of the same type that does not use generics.

IList

Represents a non-generic collection of objects that can be individually accessed by index.

IDictionary

Represents a non-generic collection of key/value pairs.

Key Classes

ArrayList

Represents a strongly typed list of objects that can be accessed by index. It grows dynamically as elements are added.

Hashtable

Represents a collection of key and value pairs that are organized based on the hash code of the key. It is not generic.

Queue

Represents a strongly typed collection of objects that can be accessed by index. The first object added is the first object retrieved.

Stack

Represents a strongly typed collection of objects that can be accessed by index. The last object added is the first object retrieved.

SortedList

Represents a collection of key/value pairs that are sorted by the keys and can be accessed by index. It is not generic.

DictionaryEntry

Represents a key and value pair that can be edited.

Related Namespaces

For more modern and type-safe collection implementations, refer to the System.Collections.Generic namespace.