Array.ConvertAll: convert all elements from one type to another type : Array ConvertAll « Data Structure « C# / CSharp Tutorial






using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;


public class MainClass
{

    public static void Main()
    {
        string[] strArray = new string[] { "75.3", "25.999", "105.25" };

        double[] doubleArray = Array.ConvertAll<string, double>(strArray, Convert.ToDouble);
        Console.Write("Converted to doubles: ");
        Array.ForEach<double>(doubleArray, delegate(double x) { Console.Write(x + " "); });
        Console.WriteLine();
    }
}
Converted to doubles: 75.3 25.999 105.25








11.19.Array ConvertAll
11.19.1.Array.ConvertAll: convert all elements from one type to another type
11.19.2.Array.ConvertAll: convert all string elements from lower case to upper case