Windows Dev Center

The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

List<T>.RemoveRange Method (Int32, Int32)


Removes a range of elements from the List<T>.

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

public void RemoveRange(
	int index,
	int count


Type: System.Int32

The zero-based starting index of the range of elements to remove.

Type: System.Int32

The number of elements to remove.

Exception Condition

index is less than 0.


count is less than 0.


index and count do not denote a valid range of elements in the List<T>.

The items are removed and all the elements following them in the List<T> have their indexes reduced by count.

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

The following example demonstrates the RemoveRange method and various other methods of the List<T> class that act on ranges. After the list has been created and modified, the RemoveRange method is used to remove two elements from the list, beginning at index location 2.

private void ovalShape1_Click(System.Object sender, System.EventArgs e)
    bool state = true;
    if (state == false)
        ovalShape1.Scale(new SizeF(2, 3));
        state = true;
        ovalShape1.Scale(new SizeF((float)0.5, ((float)0.333)));
        state = false;

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