
You want to use the Array.ConvertAll generic method to convert an array of one type of element to an array of another type. With Array.ConvertAll, you must specify a Converter function, which can be represented in a lambda expression.
Lambda ExpressionThis C# article describes the Array.ConvertAll method. It provides example programs.

To begin, this example program creates an integer array of three elements on the managed heap. Then, we invoke the Array.ConvertAll static method; you do not need to specify the type parameters, as they are inferred statically. The second argument to Array.ConvertAll is a lambda expression; the identifier 'element' is an argument name, and the lambda function returns the ToString() method result on the element.
Generic Method Static Method ToString UsageProgram that uses Array.ConvertAll method [C#]
using System;
class Program
{
static void Main()
{
// Integer array of three values.
int[] array1 = new int[3];
array1[0] = 4;
array1[1] = 5;
array1[2] = 6;
// Use ConvertAll to convert integer array to string array.
string[] array2 = Array.ConvertAll(array1, element => element.ToString());
// Write string array.
Console.WriteLine(string.Join(",", array2));
}
}
Output
4,5,6
So how does the Array.ConvertAll method work inside? First, the second argument can be considered a higher-order procedure; this argument is called each time an element is to be converted. The ConvertAll method simply allocates a new array for you, and then places the result of the converter method into each corresponding element slot.
It would be faster to write all the code yourself in a single imperative method. This would eliminate the delegate method invocations, which are more expensive than regular methods, and also the slight overhead that occurs with argument checking.
The Array.ConvertAll method allows you to declaratively convert an entire array with a single statement. Although it incurs some performance overhead, it can help simplify code, particularly in programs where many different conversions take place.
Array Types