Your question is a bit unclear:
- your
[]
seems not to be real, but rather for
\n
, etc, correct (see below)?
- do the lines need to have stripped off the leading and trailing white spaces?
- does it need to handle
\r\n
,
\n\r
,
\r
,
\n
?
BTW: See
Escaping in C#: characters, strings, string formats, keywords, identifiers[
^] for escapes in a string.
A solution may be:
public static string[] GetLines(string fullText)
{
return fullText.Split(new[] {'\n'}, StringSplitOptions.RemoveEmptyEntries)
.Select(line => line.Trim())
.ToArray();
}
Cheers
Andi