How to use C# string Split


CSharp.Net-Informations.com
SiteMap

CSharp string Split function returns an array of String containing the substrings delimited by the given System.Char array.

string[] string.split(string[] separator)

Parameters:

separator - the given delimiter

Returns:

An array of Strings delimited by one or more characters in separator


using System;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = null;
            string[] strArr = null;
            int count = 0;
            str = "CSharp split test";
            char[] splitchar = { ' ' };
            strArr = str.Split(splitchar);
            for (count = 0; count < = strArr.Length - 1; count++)
            {
                MessageBox.Show(strArr[count]);
            } 
        }
    }
}

When you execute this C# programme , you will get "CSharp" "split" "test" in separate messagebox.


  • Sponsored Program








More Source Code :
|  Home  |   VB.NET  |   C#  |   ASP.NET  |   SiteMap  |   Terms of Use  |   About  |