Snippet to split a String by a character in C# (Csharp)

This example splits a String in Csharp on a single character comma (,). C# code snippet
using System;

class Program
{
    static void Main()
    {
	string s = "one,two,three,four";

           // Split string on character comma.
	string[] words = s.Split(',');
	foreach (string word in words)
	{
	    Console.WriteLine(word);
	}
    }
}
--- Output --- one two three four

Share item with friends