Splitting a string using a delimiter
suggest changeUse 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents