List vs Array

Which Is Faster in C#, Array or List?

In C#, arrays are usually a bit faster than List for indexed access, but the gap is often small. Here is why, and how to measure it yourself.

On this page
  1. The short answer
  2. Why arrays usually win on indexing
  3. Growing is where List helps
  4. Measure it yourself
  5. For C++ readers

The short answer

In C#, an array (int[]) is usually a little faster than a List<int> for reading and writing elements by index. The gap is often small, and it depends on your code and the .NET runtime. If speed matters for your program, measure it rather than guess.

Why arrays usually win on indexing

An array is one fixed block of memory with a known length. Reading array[i] is a direct access, with the runtime checking that i is in range.

A List<T> is a wrapper around an internal array, and it also tracks how many items it holds. Reading list[i] calls the indexer, which checks the index against that count and then reads from the internal array. The extra work is small, and the JIT compiler often inlines the call, which is why the gap is often small.

Growing is where List helps

An array cannot change its length. Adding to one means allocating a new array and copying the items over. A List<T> grows for you. When its internal array is full, it allocates a larger one, typically about double the size, and copies the items. Adding is fast on average, though the occasional add that triggers growth costs more.

If you know how many items you will add, new List<int>(capacity) sets the starting capacity and avoids the repeated growth. If you look items up by value rather than by position, a different collection may suit you better. See “Why use HashSet instead of List in C#?”

Measure it yourself

A Stopwatch loop is easy to get wrong, because JIT warm-up and caching can distort the result. BenchmarkDotNet handles those details for you, and it is the standard benchmark library for .NET. Run benchmarks in Release mode. This minimal example sums the same values from an array and from a List<int>:

using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

public class ArrayVsList
{
    private int[] array;
    private List<int> list;

    [GlobalSetup]
    public void Setup()
    {
        array = new int[1000];
        list = new List<int>(1000);
        for (int i = 0; i < 1000; i++)
        {
            array[i] = i;
            list.Add(i);
        }
    }

    [Benchmark]
    public long SumArray()
    {
        long total = 0;
        for (int i = 0; i < array.Length; i++) total += array[i];
        return total;
    }

    [Benchmark]
    public long SumList()
    {
        long total = 0;
        for (int i = 0; i < list.Count; i++) total += list[i];
        return total;
    }
}

public class Program
{
    public static void Main() => BenchmarkRunner.Run<ArrayVsList>();
}

For C++ readers

The same trade-off exists in C++. A C# array corresponds to a built-in array or std::array, and C#’s List<T> corresponds to std::vector. In both languages, you choose between a fixed block that is indexed directly and a growable container with a little more bookkeeping.

In C++, operator[] on a std::vector skips the bounds check, while at() performs one. For the C++ side of the same decision, see “Should I use list or array?”

The complete guide to list vs array

List vs Array in C++
Read the guide

Keep exploring

Guides from other topics

All topics →

The Latest C++ Standard

C++23 is the most recent C++ standard at the time of writing, with C++26 next. Here is what changed, how versions are named, and how to compile for each.

C++ Standards 3 min read