System.Collections.Generic.List<T> Class
Implements the IList<T> interface. The size of a List is dynamically increased as required. A List is not guaranteed to be sorted. It is the programmer's responsibility to sort the List prior to performing operations (such as BinarySearch) that require a List to be sorted. Indexing operations are required to perform in constant access time; that is, O(1).

See Also: List<T> Members


public class List<T> : ICollection<T>, IEnumerable<T>, IList<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, IList

Type Parameters

Documentation for this section has not yet been entered.


Some methods, such as Contains, IndexOf, LastIndexOf, and Remove, use an equality comparer for the list elements. The default equality comparer for type T is determined as follows: If type T implements IEquatable<T> then the default equality comparer is IEquatable;T>.Equals(T); otherwise the default equality comparer is object.Equals(Object).

Some methods, such as BinarySearch and Sort, use a comparer for the list elements. Some overloads of these methods take an explicit comparer as argument, while others use a default comparer. The default comparer for type T is determined as follows: If type T implements System.IComparable<T> then the default comparer is IComparable<T>.CompareTo(T); otherwise, if type T implements IComparable then the default comparer is IComparable.CompareTo(Object). If type T implements neither IComparable<T> nor IComparable then there is no default comparer; in this case a comparer or comparison delegate must be given explicitly.

The capacity of a List<T> is the number of elements the List<T> can hold. As elements are added to a List<T>, the capacity is automatically increased as required.. The capacity can be decreased by calling List<T>.TrimToSize or by setting the List<T>.Capacity property explicitly.

Indexes in this collection are zero-based.

List<T> accepts null as a valid value for reference types and allows duplicate elements.

This type contains a member that is a nested type, called Enumerator. Although Enumerator is a member of this type, Enumerator is not described here; instead, it is described in its own entry, List<T>.Enumerator.


Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0