C# List RemoveRange() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
List

Definition

In C#, List.RemoveRange(index, count) removes a block of neighbouring items in one call. You give it where to start and how many items to delete.

The items after the block slide left and Count drops by count. It is the quick way to cut off the first few items or the whole tail of a list, instead of calling RemoveAt() over and over.

This is an instance member of List<T> (System.Collections.Generic). Call it on a list variable, such as numbers.RemoveRange(...). A List<T> is a class, so two variables can share one list. It keeps items in the order you put them, allows duplicates, and grows when needed. An array, by comparison, has a fixed length.

Syntax

Pass the starting index and the number of items to remove (not the end index).

C#
List<int> numbers = new List<int> { 10, 20, 30, 40, 50 };
numbers.RemoveRange(1, 2);    // removes 20 and 30
// numbers is now 10, 40, 50
CallWhat it does
numbers.RemoveRange(0, 2)Removes the first two items.
numbers.RemoveRange(2, numbers.Count - 2)Removes everything from index 2 to the end.
numbers.RemoveRange(1, 0)Allowed. A count of 0 removes nothing.

The second parameter is a count, not an end index. If index or count is negative, you get ArgumentOutOfRangeException. If index + count is more than Count, you get ArgumentException. In both cases the list is not changed. The cost is O(n), and the items after the block move only once.

Library declarations
C#
public void RemoveRange(int index, int count);

Parameters

ParameterDescription
indexRequired. The zero-based position of the first item to remove.
countRequired. How many items to remove. index + count must not be more than Count.

Return Value

Return ValueDescription
voidNothing is returned. The block is removed in place and Count drops by count.

C# Examples

Example 1 — Remove the Middle Items

Remove two items starting at index 1 from a list of five.

C#
using System;
using System.Collections.Generic;

class Program {
    static void Main() {
        List<int> numbers = new List<int> { 10, 20, 30, 40, 50 };

        numbers.RemoveRange(1, 2);

        Console.WriteLine(string.Join(", ", numbers));
        Console.WriteLine(numbers.Count);
    }
}

How It Works

  1. Start and size. 1 is the start index and 2 is how many items to delete: the items at index 1 and index 2.
  2. Which items. Index 1 holds 20 and index 2 holds 30. Those two are removed.
  3. Tail slides left. 40 and 50 move down to indexes 1 and 2, right after 10.
  4. Count drops by two. Five items minus the block of two leaves 3 items.

Example 2 — Remove the First Items and the Tail

Drop the first two items, then drop everything from index 2 to the end.

C#
using System;
using System.Collections.Generic;

class Program {
    static void Main() {
        List<string> days = new List<string> { "Mon", "Tue", "Wed", "Thu", "Fri" };

        days.RemoveRange(0, 2);
        Console.WriteLine(string.Join(", ", days));

        days.RemoveRange(1, days.Count - 1);
        Console.WriteLine(string.Join(", ", days));
    }
}

How It Works

  1. Front trim. RemoveRange(0, 2) deletes "Mon" and "Tue", so "Wed" becomes index 0.
  2. Tail trim. The list now has 3 items. days.Count - 1 is 2, the number of items after index 0.
  3. Everything after. Removing 2 items from index 1 deletes "Thu" and "Fri", which is the whole tail.
  4. Result. Only "Wed" is left. Using Count - index for the count always reaches exactly to the end.

Example 3 — A Range That Is Too Long

Ask for more items than the list has after the index. The call fails and the list stays the same.

C#
using System;
using System.Collections.Generic;

class Program {
    static void Main() {
        List<int> list = new List<int> { 1, 2, 3, 4 };

        try {
            list.RemoveRange(2, 5);
        } catch (ArgumentException) {
            Console.WriteLine("range is too long");
        }

        list.RemoveRange(2, 0);
        Console.WriteLine(string.Join(", ", list));
    }
}

How It Works

  1. Too many items. From index 2 only two items exist (3 and 4), but the call asks for five.
  2. Exception type. For a range that goes past the end, the list throws ArgumentException. A negative number would throw its child type, ArgumentOutOfRangeException, which this catch block also handles.
  3. All or nothing. The failed call does not remove a partial block. The list is still 1, 2, 3, 4.
  4. Count 0 is fine. RemoveRange(2, 0) is a legal call that simply does nothing.

Frequently Asked Questions

It removes a block of count items that begins at the given index, and moves the later items to the left.
No. It is the number of items to remove. RemoveRange(1, 3) removes the items at indexes 1, 2, and 3.
RemoveRange throws ArgumentException (or ArgumentOutOfRangeException for negative values) and leaves the list unchanged.
Use list.RemoveRange(index, list.Count - index). Make sure index is not above Count.
RemoveRange deletes the block from the list. GetRange copies the block into a new list and leaves the original untouched.

Next: Reverse()

Reverse the order of the items in the List, in place; optionally only a range.

Reverse() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful