C# List ConvertAll() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
List

Definition

In C#, List.ConvertAll(converter) maps every item of a list to something new. You give it a small function (a Converter<TInput, TOutput>) that takes one item and returns the converted item, usually as a lambda such as n => n.ToString().

The method returns a new list of the output type, with one converted item for each source item and in the same order. The original list is not changed. The new type can differ: List<int> in, List<string> out. It is the List version of LINQ's Select, and the instance version of Array.ConvertAll.

This is an instance member of List<T> (System.Collections.Generic). Call it on a list variable, such as numbers.ConvertAll(...). 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 a lambda that returns the converted item. The compiler works out the output type from the lambda.

C#
List<int> numbers = new List<int> { 1, 2, 3 };
List<string> labels = numbers.ConvertAll(n => "#" + n);       // "#1", "#2", "#3"
List<int> doubled = numbers.ConvertAll(n => n * 2);           // 2, 4, 6
CallWhat it does
numbers.ConvertAll(n => n * 2)A new List<int> with each number doubled.
words.ConvertAll<int>(int.Parse)Convert text to numbers by passing a method name.
people.ConvertAll(p => p.Name)Pull one field out of every object.

ConvertAll always returns a List<TOutput>, even for an empty source (an empty list). A null converter throws ArgumentNullException. If the converter throws (for example, int.Parse on bad text), the exception comes out of ConvertAll and no list is returned. LINQ Select(...).ToList() gives the same result and works on any collection.

Library declarations
C#
public List<TOutput> ConvertAll<TOutput>(Converter<T, TOutput> converter);

Parameters

ParameterDescription
converterRequired. A Converter<T, TOutput>: a lambda or method that takes one item of type T and returns the converted item. It must not be null.

Return Value

Return ValueDescription
ListA new list with the converted items, in the same order and with the same Count as the source. The source is unchanged.

C# Examples

Example 1 — Convert Numbers to Text

Make a list of labels from a list of numbers. The two lists have different item types.

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

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

        List<string> labels = numbers.ConvertAll(n => "#" + n);

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

How It Works

  1. One call per item. The lambda n => "#" + n runs for 1, 2, and 3 and returns a string each time.
  2. Type is worked out. The lambda returns a string, so the compiler knows the result is a List<string>. You did not have to write the type.
  3. Source stays numbers. The second line shows the original List<int> was not modified.
  4. Same size. Three items in, three items out. Order is kept.

Example 2 — Convert Text to Numbers

Pass a method name instead of a lambda. int.Parse takes a string and returns an int, so it fits.

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

class Program {
    static void Main() {
        List<string> words = new List<string> { "10", "20", "30" };

        List<int> numbers = words.ConvertAll<int>(int.Parse);

        int total = 0;
        foreach (int n in numbers) {
            total += n;
        }

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

How It Works

  1. Method group. int.Parse has the right shape (string in, int out), so it can be passed as the converter, with no lambda.
  2. Explicit type. ConvertAll<int> names the output type, which helps the compiler pick the right overload of Parse.
  3. Now they are numbers. The loop can add the values, because they are int items and no longer text.
  4. Bad text throws. A word like "abc" would make int.Parse throw FormatException. Use int.TryParse in your own loop when input may be bad.

Example 3 — Pull Names Out of Objects

Convert a list of objects into a list of one of their fields.

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

class Person {
    public string Name;
    public int Age;
}

class Program {
    static void Main() {
        List<Person> people = new List<Person> {
            new Person { Name = "Asha", Age = 30 },
            new Person { Name = "Ben", Age = 17 }
        };

        List<string> names = people.ConvertAll(p => p.Name);
        List<bool> adults = people.ConvertAll(p => p.Age >= 18);

        Console.WriteLine(string.Join(", ", names));
        Console.WriteLine(string.Join(", ", adults));
    }
}

How It Works

  1. One field. p => p.Name returns just the name of each Person, so the result is a List<string>.
  2. A computed value. p => p.Age >= 18 returns a bool for each person, so the result is a List<bool>.
  3. Same order. Both result lists follow the order of people: Asha first, Ben second.
  4. Strings, not objects. The new lists do not hold Person objects, so changing them cannot change the people.

Frequently Asked Questions

It creates a new list by running a converter function on every item of the list. The new list can have a different item type.
No. The source list stays as it is. You get a new List<TOutput>.
A Converter<TInput, TOutput> is a delegate: a function that takes one item and returns the converted item. In C# you usually write it as a lambda, such as n => n * 2.
ConvertAll is a List<T> method that returns a List<TOutput> right away. Select works on any collection and is lazy, so you need ToList() to get a list.
The exception comes out of ConvertAll and no new list is returned. For example, int.Parse on text that is not a number throws FormatException.

Next: CopyTo()

Copy items from the List into an existing array, starting at a chosen position.

CopyTo() 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