xxxxxxxxxx
string input = "line1\r\nline2\r\nline3\r\n";
string[] lines = input.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
xxxxxxxxxx
// To split a string by newlines, see below (requires 'System')
using System
text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
xxxxxxxxxx
string input = "line 1\nline 2\nline 3";
string[] lines = input.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
foreach (string line in lines)
{
Console.WriteLine(line);
}
xxxxxxxxxx
string[] lines = theText.Split(
new string[] { "\r\n", "\r", "\n" },
StringSplitOptions.None
);