Mega Code Archive

 
Categories / C# Book / 02 Essential Types
 

0244 Split string

Split method splits a string by specified characters and returns an array of strings. By default Split method uses space as the separator. using System; class Sample { public static void Main() { string s = "this is a test from rntsoft.com"; string[] arr = s.Split(); foreach (string ss in arr) { Console.WriteLine(ss); } } } The output: this is a test from rntsoft.com