TextParser.Parser.GetLineNumber C# (CSharp) Method

GetLineNumber() public method

Gets the number of lines the text has.
public GetLineNumber ( ) : int
return int
        public int GetLineNumber()
        {
            if(text == null || text.Length == 0) {
                return 0;
            }

            int ct = 1;
            bool wasNewLine = false;

            for(int i = 0; i < text.Length; i++) {
                if(wasNewLine) {
                    ct++;
                    wasNewLine = false;
                }

                if(text[i] == '\n') {
                    wasNewLine = true;
                }
            }

            return ct;
        }