string[] result = input.Split(new string[] {"
", "
"}, StringSplitOptions.RemoveEmptyEntries);
This covers both
and
newline types and removes any empty lines your users may enter.
I tested using the following code:
string test = "PersonA
PersonB
PersonC
";
string[] result = test.Split(new string[] {"
", "
"}, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in result)
Console.WriteLine(s);
And it works correctly, splitting into a three string array with entries "PersonA", "PersonB" and "PersonC".
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…