Split a string in C#

Split a string in C#

using System;

public class Program
{
    public static void Main()
    {
        Console.WriteLine("Split a string in C#\n");
        string MainString = "Lorem Ipsum is simply dummy text.";
        string[] split = MainString.Split(new Char[] { ' ' });
        // set a delegate for the ShowSquares method
        Action<string> action = new Action<string>(ShowSquares);
        Array.ForEach(split, action);
    }

    private static void ShowSquares(string val)
    {
        Console.WriteLine("{0}", val, val);
    }
}
DEMO
Split a string in C# Split a string in C# Reviewed by Bhaumik Patel on 8:33 PM Rating: 5