c# split word code example
Example 1: c# split a string and return list
listStrLineElements = line.Split(',').ToList();
Example 2: split string in c#
string phrase = "The quick brown fox jumps over the lazy dog.";
string[] words = phrase.Split(' ');
foreach (var word in words)
{
System.Console.WriteLine($"<{word}>");
}
Example 3: split using string c#
data.Split(new string[] { "xx" }, StringSplitOptions.None);
Example 4: c# split string
string sentence = "Hello Beautiful World";
string[] words = sentence.Split(' ');
foreach (string word in words) {
print(word);
}
Example 5: string split c#
char[] delimiterChars = { ' ', ',', '.', ':', '\t' };
string text = "one\ttwo three:four,five six seven";
System.Console.WriteLine($"Original text: '{text}'");
string[] words = text.Split(delimiterChars);
System.Console.WriteLine($"{words.Length} words in text:");
foreach (var word in words)
{
System.Console.WriteLine($"<{word}>");
}