private int CountRemainingQuotesOnLine(int tagEnd, char quote) { int startPosition = _cs.Position; int quoteCount = 0; while (!_cs.IsEndOfStream() && _cs.Position < tagEnd) { char currentChar = _cs.CurrentChar; if (currentChar == quote) { quoteCount++; } else if (CharacterStream.IsNewLine(currentChar)) { break; } _cs.MoveToNextChar(); } // reset the stream back to it's original position _cs.Position = startPosition; return(quoteCount); }