xxxxxxxxxx
string input = "apple,banana,orange";
string[] words = input.Split(',');
foreach (string word in words)
{
Console.WriteLine(word);
}
xxxxxxxxxx
We can specify how many substrings to return using string.Split:
string myString = "Mahesh,Kumar,Yadav"
var pieces = myString.Split(new[] { ',' }, 2);
Returns:
------------------
Mahesh
Kumar,Yadav