How to

split string to array

Published: 13. December 2008 | Updated: 26. October 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » Arrays
Tags: Array C#
Was this snippet helpful for you? YESYES / NONO
char[] separators = { ',', ';' };

string text = "123,8946;6456,466,994,105;4";
string[] parts = text.Split(separators);

foreach (string part in parts)
{
    Console.WriteLine(part);
}
Console Output:
123
8946
6456
466
994
105
4
Send us feedback about this snippet »



Related Snippets: