.NET API Documentation

IList<T> Interface

System.Collections.Generic
Interface

Represents a strongly typed list of objects that can be accessed by index. The IList<T> interface is the base interface for the List<T> class.

Syntax

public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable

Type Parameters

T
The type of elements in the list. This type parameter is contravariant. That is, you can use either the type you specified or any compatible type. For example, if you have an IList<string>, you can access elements in that list as object.

Remarks

The IList<T> interface inherits from ICollection<T>, which in turn inherits from IEnumerable<T> and IEnumerable. Therefore, it contains all the members of those interfaces.

The IList<T> interface adds the following members:

The IList<T> interface is the base interface for the List<T> class. The List<T> class implements the IList<T> interface and provides a fully functional collection that can be accessed by index.

Methods

Add(T item)

Adds an object to the end of the IList<T>.

void Add(T item);

Contains(T item)

Determines whether an element is in the IList<T>.

bool Contains(T item);

IndexOf(T item)

Searches for the specified object and returns the zero-based index of the first occurrence within the entire IList<T>.

int IndexOf(T item);

Insert(int index, T item)

Inserts an element into the IList<T> at the specified index.

void Insert(int index, T item);

Remove(T item)

Removes the first occurrence of a specific object from the IList<T>.

void Remove(T item);

RemoveAt(int index)

Removes the element at the specified index of the IList<T>.

void RemoveAt(int index);

Properties

this[int index]

Gets or sets the element at the specified index.

T this[int index] { get; set; }

See Also