>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());Using that approach, it resolves the issue.
' Load the string into the string builder ' expC1 String Public Function LoadString(ByVal tcString As String) As Boolean Dim lcDelimiter As String() = New String() {Environment.NewLine} ' Make sure to clear the string builder oStringBuilder.Length = 0 oStringBuilder.Append(tcString) ' Initialize the array oLine = oStringBuilder.ToString.Split(lcDelimiter, StringSplitOptions.None) ' Count the number of lines nLine = MemLines() Return (True) End Function ' Return the number of lines in a string Public Function MemLines() As Integer Return oLine.Length End Function ' Return the specific line in a string ' expN1 Line Public Function MLine(ByVal tnLine As Integer) As Boolean ' Reset the values cLine = "" ' If the value passed is smaller or eqaul to the number of lines If tnLine - 1 <= nLine Then cLine = oLine(tnLine - 1) End If Return True End FunctionBefore, I was using a direct reference to Environment.NewLine.ToCharArray in this line:
oLine = oStringBuilder.ToString.Split(Environment.NewLine.ToCharArray, StringSplitOptions.None)Now, I am using the String() approach. So, maybe this is why it didn't work before.