Source:
http://www.dotnetperls.com/string-split
using System;
class Program
{
static void Main()
{
//
// This string is also separated by Windows line breaks.
//
string value = "shirt\r\ndress\r\npants\r\njacket";
//
// Use a new char[] array of two characters (\r and \n) to break
// lines from into separate strings. Use "RemoveEmptyEntries"
// to make sure no empty strings get put in the string[] array.
//
char[] delimiters = new char[] { '\r', '\n' };
string[] parts = value.Split(delimiters,
StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < parts.Length; i++)
{
Console.WriteLine(parts[i]);
}
//
// Same as the previous example, but uses a new string of 2 characters.
//
parts = value.Split(new string[] { "\r\n" }, StringSplitOptions.None);
for (int i = 0; i < parts.Length; i++)
{
Console.WriteLine(parts[i]);
}
}
}