Array.ConvertAll: convert all string elements from lower case to upper case : 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[] strArray2 = new string[] { "Blah", "Foo", "Canonical" };
        Console.Write("Before converting to-upper: ");
        Array.ForEach<string>(strArray2, delegate(string x) { Console.Write(x + " "); });
        Console.WriteLine();

        string[] revArray = Array.ConvertAll<string, string>(strArray2, delegate(string s) { return s.ToUpper(); });
        Console.Write("Converted to upper-case: ");
        Array.ForEach<string>(revArray, delegate(string x) { Console.Write(x + " "); });
        Console.WriteLine();
    }
}
Before converting to-upper: Blah Foo Canonical
Converted to upper-case: BLAH FOO CANONICAL








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