System.Collections.Generic Namespace

This namespace provides interfaces and classes that define generic collections, which allow programmers to create collections of objects that are strongly typed, perform better, and are safer than non-generic collections.

Generic collections are implemented in the .NET Framework and are available in the System.Collections.Generic namespace.

Key Concepts

Commonly Used Generic Collections

List<T>

Represents a list of objects that can be accessed by index. It is a resizable array.

API Reference →

Dictionary<TKey, TValue>

Represents a collection of key/value pairs that are sorted by key. It provides efficient lookups based on the key.

API Reference →

HashSet<T>

Represents a set of values. A set is a collection that contains no duplicate elements and has no defined order.

API Reference →

Queue<T>

Represents a first-in, first-out (FIFO) collection of objects. Elements are added to the end and removed from the beginning.

API Reference →

Stack<T>

Represents a last-in, first-out (LIFO) collection of objects. Elements are added to the end and removed from the beginning.

API Reference →

LinkedList<T>

Represents a doubly linked list. It provides O(1) time complexity for adding or removing elements at any point in the list.

API Reference →

Interfaces

The System.Collections.Generic namespace also defines a set of powerful interfaces that form the foundation for all generic collection types: