Sponsored Ad

Tuesday, January 11, 2011

String Splitting using Array of Delimiters: C#

This program will help you to break(split) is given string on the basis of multiple delimiters given in a array. for example we used { ' ', ',', ':' } array of delimiters to split the given string. The other parameter in split function is maximum number of results returned after split.

 

String Splitting using Array of Delimiters: C#

C# Code to Split String on multiple Delimiters:

using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string my_sites = "SoftwareTestingNet.com,IndiHub.com TestingWiz.com,SharePointBank.com:CsharpHub.com";
            char[] cdelimiters = { ' ', ',', ':' };

            string[] sResults  = my_sites.Split(cdelimiters, 10);
            foreach (string str_name in sResults)
            {
                Console.WriteLine(str_name);
            }
            Console.ReadLine();
        }
    }
}

0 comments:

Post a Comment

Sponsored Ad

Website Update

Followers