← Interactive API Explorer
Namespace: System.Collections.Generic

List<T>

Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.

Properties (2)

int Count
Gets the number of elements contained in the List.
Value: The number of elements contained in the List.
T Item(Int32)
Gets or sets the element at the specified index.
Value: The element at the specified index.

Methods (7)

void Add(T)
Adds an object to the end of the List.
ParameterDescription
itemThe object to be added to the end of the List. The value can be null for reference types.
void Insert(Int32,T)
Inserts an element into the List at the specified index.
ParameterDescription
indexThe zero-based index at which item should be inserted.
itemThe object to insert. The value can be null for reference types.
void RemoveAt(Int32)
Removes the element at the specified index of the List.
ParameterDescription
indexThe zero-based index of the element to remove.
bool Remove(T)
Removes the first occurrence of a specific object from the List.
ParameterDescription
itemThe object to remove from the List. The value can be null for reference types.
Returns: true if item is successfully removed; otherwise, false. This method also returns false if item was not found in the List.
void AddRange(IEnumerable<T>)
Adds the elements of the specified collection to the end of the List.
ParameterDescription
collectionThe collection whose elements should be added to the end of the List. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.
void Clear
Removes all elements from the List.
Enumerator<T> GetEnumerator
Returns an enumerator that iterates through the List.
Returns: A Enumerator for the List.