Sponsored Ad

Tuesday, January 11, 2011

How to Break Comma Separated String using C#

This program will help you to break(split) the given string by specifying the delimiter in split() function. you can break the string by using any other char also. This operation will return a array of string. 

How to Break Comma Separated String using C#

C# Code to split a string using comma as a delimiter:

using System;
using System.ServiceProcess;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string strDemo = "SoftwareTestingNet.com,IndiHub.com,TestingWiz.com,SharePointBank.com";
            //Pass appropriate delimeter to split the string, it can be any char.
            string[] my_Sites = strDemo.Split(',');
            foreach (string Site_Name in my_Sites)
            {
                Console.WriteLine(Site_Name);
            }          
            Console.ReadLine();
        }
    }
}

0 comments:

Post a Comment

Sponsored Ad

Website Update

Followers