Splitting a string using a delimiter C# with Example



Splitting a string using a delimiter C# with Example

Use the System.String.Split method to return a string array that contains substrings of the original string, split 
based on a specified delimiter: 
string sentence = "One Two Three Four"; 
string[] stringArray = sentence.Split(' '); 
foreach (string word in stringArray) 
{ 
Console.WriteLine(word); 
} 
Output: 
One 
Two 
Three 
Four 

0 Comment's

Comment Form

Submit Comment