Array.ConvertAll converts an entire array. This method converts all elements in one array to another type. We specify the conversion function—this can be done in the lambda expression syntax form.
Example. To begin, this example program creates an integer array of 3 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.
Internals. 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.
Note The ConvertAll method allocates a new array and then places the result of the converter method into each corresponding element slot.
C# program that uses Array.ConvertAll method
static void Main()
// Integer array of 3 values.
int array1 = new int;
array1 = 4;
array1 = 5;
array1 = 6;
// Use ConvertAll to convert integer array to string array.
string array2 = Array.ConvertAll(array1,
element => element.ToString());
// Write string array.
It would be faster to write an imperative method. This would eliminate the delegate method invocations (which are more expensive than regular methods) and the slight overhead that occurs with argument checking.
Summary. The Array.ConvertAll method allows you to declaratively convert an entire array with a single statement. It incurs some performance overhead. But it can simplify code, particularly in programs where many different conversions take place.