C# List RemoveAt() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
List

Definition

In C#, List.RemoveAt(index) deletes the item at one position. The index is zero-based, so 0 is the first item and Count - 1 is the last.

All items after that position slide one place to the left, and Count drops by 1. Use it when you know where an item is. When you know what the item is, Remove() is the better choice.

This is an instance member of List<T> (System.Collections.Generic). Call it on a list variable, such as numbers.RemoveAt(...). 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 index of the item to delete. The valid range is 0 to Count - 1.

C#
List<string> names = new List<string> { "Asha", "Ben", "Chen" };
names.RemoveAt(1);                   // Asha, Chen
names.RemoveAt(names.Count - 1);     // Asha
CallWhat it does
names.RemoveAt(0)Removes the first item. Everything else moves left by one.
names.RemoveAt(names.Count - 1)Removes the last item. Nothing needs to shift, so it is fast.
names.RemoveAt(names.Count)Throws ArgumentOutOfRangeException. There is no item at index Count.

RemoveAt is O(n) in general because of the shift, but removing the last item is O(1). A negative index or an index of Count or more throws ArgumentOutOfRangeException. The method returns void, so read the item first if you still need it: var item = list[i]; list.RemoveAt(i);.

Library declarations
C#
public void RemoveAt(int index);

Parameters

ParameterDescription
indexRequired. The zero-based position of the item to delete. It must be from 0 to Count - 1.

Return Value

Return ValueDescription
voidNothing is returned. The item is gone and Count is one less. The removed value is not handed back.

C# Examples

Example 1 — Remove the Second Item

Delete the item at index 1 and watch the later item slide into its place.

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

class Program {
    static void Main() {
        List<string> names = new List<string> { "Asha", "Ben", "Chen" };

        names.RemoveAt(1);

        Console.WriteLine(string.Join(", ", names));
        Console.WriteLine(names.Count);
        Console.WriteLine(names[1]);
    }
}

How It Works

  1. Position 1. Index 0 is "Asha" and index 1 is "Ben", so "Ben" is the item that is deleted.
  2. Slide left. "Chen" was at index 2 and moves to index 1. The list has no hole.
  3. Smaller count. Three items minus one leaves Count equal to 2.
  4. Same index, new item. names[1] used to be "Ben". Now it reads "Chen".

Example 2 — The Last Valid Index

Remove the last item with Count - 1, then see what happens with an index equal to Count.

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

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

        list.RemoveAt(list.Count - 1);
        Console.WriteLine(string.Join(", ", list));

        try {
            list.RemoveAt(list.Count);
        } catch (ArgumentOutOfRangeException) {
            Console.WriteLine("no item at index " + list.Count);
        }

        Console.WriteLine(list.Count);
    }
}

How It Works

  1. Last item. With 3 items, Count - 1 is 2. RemoveAt(2) deletes 30, and nothing else has to move.
  2. Count is off the end. Now Count is 2, and the valid indexes are only 0 and 1. RemoveAt(2) asks for a slot that does not exist.
  3. Exception is caught. ArgumentOutOfRangeException is thrown, the catch block prints a message, and the program goes on.
  4. List untouched. The failed call removed nothing, so Count is still 2.

Example 3 — Remove Even Numbers in a Loop

Go from the end to the start so that each removal does not disturb the indexes you have not visited yet.

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

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

        for (int i = numbers.Count - 1; i >= 0; i--) {
            if (numbers[i] % 2 == 0) {
                numbers.RemoveAt(i);
            }
        }

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

How It Works

  1. Start at the end. i begins at Count - 1 and counts down to 0, so the loop reads the list from right to left.
  2. Test then remove. When numbers[i] is even, RemoveAt(i) deletes it. Only items to the right of i shift, and those were already checked.
  3. Why not forwards. In a forward loop, deleting index 1 moves the next item into index 1, and the loop then jumps past it. Going backwards avoids that.
  4. Shorter way. numbers.RemoveAll(n => n % 2 == 0) does the same job in one line, with the loop written for you.

Frequently Asked Questions

It deletes the item at the index you pass and moves every later item one place to the left. Count goes down by 1.
RemoveAt throws ArgumentOutOfRangeException when the index is negative or equal to or greater than Count. The list is not changed.
No, it returns void. Read the item with list[index] before you call RemoveAt if you still need it.
Call list.RemoveAt(list.Count - 1). Check that Count is above 0 first, because an empty list has no last item.
Use a for loop that counts down from Count - 1 to 0, or call RemoveAll with a predicate. A foreach over the same list throws InvalidOperationException when the list changes.

Next: RemoveRange()

Remove a block of count items that starts at a given index.

RemoveRange() 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.

13 people found this page helpful