System.IO.TextReader.ReadLine C# (CSharp) Method

ReadLine() public method

public ReadLine ( ) : string
return string
        public virtual string ReadLine()
        {
            StringBuilder sb = new StringBuilder();
            while (true)
            {
                int ch = Read();
                if (ch == -1) break;
                if (ch == '\r' || ch == '\n')
                {
                    if (ch == '\r' && Peek() == '\n')
                    {
                        Read();
                    }

                    return sb.ToString();
                }
                sb.Append((char)ch);
            }
            if (sb.Length > 0)
            {
                return sb.ToString();
            }

            return null;
        }

Usage Example

Example #1
0
    public CustomerAccount(System.IO.TextReader textIn)
    {
        name = textIn.ReadLine();
        string balanceText = textIn.ReadLine();

        balance = decimal.Parse(balanceText);
    }
All Usage Examples Of System.IO.TextReader::ReadLine