List<T>::RemoveAt Method (Int32)

 

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

Namespace:   System.Collections.Generic
Assembly:  mscorlib (in mscorlib.dll)

public:
virtual void RemoveAt(
	int index
) sealed

Parameters

index
Type: System::Int32

The zero-based index of the element to remove.

Exception Condition
ArgumentOutOfRangeException

index is less than 0.

-or-

index is equal to or greater than Count.

When you call RemoveAt to remove an item, the remaining items in the list are renumbered to replace the removed item. For example, if you remove the item at index 3, the item at index 4 is moved to the 3 position. In addition, the number of items in the list (as represented by the Count property) is reduced by 1.

This method is an O(n) operation, where n is (Count - index).

The following example demonstrates how to add, remove, and insert a simple business object in a List<T>.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: