string[] delimiters = new string[] { Environment.NewLine }; //may be safer than "\r\n" ? string[] lines = TestString.Split(delimiters,StringSplitOptions.None);Again I don't know if performance will be an issue but with 100000 lines of about 100 characters each this is still a sub-millisecond operation on my (average) machine. Ran out of ram trying a million lines tho :-{
string[] lines = TestString.Replace("\r",String.Empty).Split("\n".ToCharArray());>Wait a minute, I've come up with another iteration of this and this time it will not remove your empty lines. Dunno why I didn't think of it earlier:
>string CRLF = "\r\n"; >string CR = "\r"; >string LF = "\n"; >string TestString = string.Format("Test this string. {0}It contains {1}{2}a blank line.", CRLF, CRLF, CRLF); >// first replace the LFs >TestString = TestString.Replace(LF, ""); >// then split on the CRs >string[] lines = TestString.Split(CR.ToCharArray()); > >for (int i = 0; i < lines.Length; i++) >{ > Debug.WriteLine(lines[i]); >} >>