public interface IList<T>: ICollection<T>, IEnumerable<T>
This type implements ICollection<T> and IEnumerable<T>.
mscorlib
BCL
Represents a collection of objects that can be individually accessed by index.
This interface is a descendant of the ICollection<T> interface and is the base interface of all generic lists.
System.Collections.Generic Namespace
IList<T> Methods
IList<T>.IndexOf Method
IList<T>.Insert Method
IList<T>.RemoveAt Method
IList<T> Properties
int IndexOf(T value)
Determines the index of a specific item in the current instance.
- value
- The
T
to locate in the current instance.
The index of value if found in the current instance; otherwise, -1.
Implementations can vary in how they determine equality of objects; for example, List<T> uses the default comparer, whereas, System.Collections.Generic.Dictionary<T,U> allows the user to specify the IComparer<T> implementation to use for comparing keys.
System.Collections.Generic.IList<T> Interface, System.Collections.Generic Namespace
void Insert(int index, T value)
Inserts an item into the current instance at the specified position.
- index
- A System.Int32 that specifies the zero-based index at which value is inserted.
- value
- The
T
to insert into the current instance.
Exception Type Condition ArgumentOutOfRangeException index is not a valid index in the current instance (i.e. is negative or greater than the number of elements in the current instance).
NotSupportedException The current instance is read-only.
In collections of contiguous elements, such as lists, the elements that follow the insertion point have indices one more than previously, to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated.[Behaviors: If index equals the number of items in the System.Collections.Generic.IList<T>, then value is required to be appended to the end of the current instance.
]
System.Collections.Generic.IList<T> Interface, System.Collections.Generic Namespace
void RemoveAt(int index)
Removes the item at the specified index of the current instance.
- index
- A System.Int32 that specifies the zero-based index of the item to remove.
Exception Type Condition ArgumentOutOfRangeException index is not a valid index in the current instance.
NotSupportedException The current instance is read-only.
In collections of contiguous elements, such as lists, the elements that follow the removed element have indices one less than previously. If the collection is indexed, the indexes of the elements that are moved are also updated.
System.Collections.Generic.IList<T> Interface, System.Collections.Generic Namespace
T this[int index] { get; set; }
Gets or sets the element at the specified index in the current instance.
- index
- The zero-based index of the element to get or set.
The element at the specified index in the current instance.
Exception Type Condition ArgumentOutOfRangeException index is not a valid index in the current instance.
NotSupportedException The property is being set and the current instance is read-only.
This property provides the ability to access a specific element in the collection by using some language-specific syntax.
System.Collections.Generic.IList<T> Interface, System.Collections.Generic Namespace