public static SplitLines ( string source ) : string[] | ||
source | string | String to split |
return | string[] |
public static string[] SplitLines(string source)
{
List<string> res = new List<string>();
int pos = 0;
int sourceLength = source.Length;
while (pos < sourceLength)
{
int eol = source.IndexOfAny(Separators, pos);
string s;
if (eol < 0)
{
s = source.Substring(pos);
pos = sourceLength;
}
else
{
s = source.Substring(pos, eol - pos);
char ch = source[eol];
eol++;
if (ch == ReturnLine && eol < sourceLength)
{
if (source[eol] == NewLine) eol++;
}
pos = eol;
}
res.Add(s);
}
return res.ToArray();
}