C# Array ConvertAll() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

In C#, Array.ConvertAll builds a new array by running a converter function on each element. The output type can differ from the input type—for example int[] to string[].

The converter is often a lambda: x => x.ToString(). The source array is not modified.

This is a static member of System.Array. You call it with the class name, such as Array.ConvertAll(...). Arrays in C# have a fixed length after creation; use List<T> when the count must grow.

Syntax

Pass the source array and a converter. Store the new result array.

C#
string[] text = Array.ConvertAll(nums, x => x.ToString());
int[] lens = Array.ConvertAll(names, n => n.Length);
CallWhat it does
Array.ConvertAll(nums, x => x.ToString())Each int becomes its string form.
Array.ConvertAll(names, n => n.ToUpper())Each name becomes uppercase.

FindAll filters (same type, fewer items). ConvertAll maps (same count, possibly new type).

Library declarations
C#
public static TOutput[] ConvertAll<TInput, TOutput>(
    TInput[] array, Converter<TInput, TOutput> converter);

Parameters

ParameterDescription
arrayRequired. Source TInput[].
converterRequired. Function from TInput to TOutput.

Return Value

Return ValueDescription
TOutput[]New array with one converted element per source element.

C# Examples

Example 1 — Ints to Strings

Convert each number to text for joining.

C#
using System;

class Program {
    static void Main() {
        int[] nums = { 1, 2, 3 };
        string[] text = Array.ConvertAll(nums, x => x.ToString());
        Console.WriteLine(string.Join("-", text));
    }
}

How It Works

  1. New type. Result is string[].
  2. Same length. Three inputs → three outputs.
  3. Lambda map. ToString on each int.
  4. Join works. string.Join needs strings.

Example 2 — Strings to Lengths

Map each name to its character count.

C#
using System;

class Program {
    static void Main() {
        string[] names = { "Ann", "Bob", "Carla" };
        int[] lens = Array.ConvertAll(names, n => n.Length);
        Console.WriteLine(string.Join(", ", lens));
    }
}

How It Works

  1. n.Length. Converter returns an int.
  2. Ann/Bob → 3. Carla → 5.
  3. Source intact. names still holds strings.
  4. Parallel array. lens[i] describes names[i].

Example 3 — Scale Numbers

Multiply every value to build a new int array.

C#
using System;

class Program {
    static void Main() {
        int[] nums = { 2, 4, 5 };
        int[] doubled = Array.ConvertAll(nums, x => x * 2);
        Console.WriteLine("src:  " + string.Join(", ", nums));
        Console.WriteLine("dest: " + string.Join(", ", doubled));
    }
}

How It Works

  1. Pure map. Each output is input × 2.
  2. Independent arrays. Changing dest later would not alter src.
  3. Same element type. TInput and TOutput can both be int.
  4. Vs ForEach. ForEach would not return doubled values.

Frequently Asked Questions

It creates a new array by converting each element with a converter function.
No. It returns a new array.
FindAll filters elements (same type). ConvertAll transforms each element (possibly new type) and keeps the same count.
Yes. That is a main use case, such as int[] to string[].
Yes. One output element per input element.

Next: Copy()

Copy a range of elements from one array to another with System.Array.

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

12 people found this page helpful