System.IO.StreamReader.Read Method

Reads the next character from the input stream and advances the character position by one character.

Syntax

public override int Read ()

Returns

The next character from the input stream represented as an int object, or -1 if no more characters are available.

Exceptions

TypeReason
System.IO.IOExceptionAn I/O error occurred.

Remarks

This method overrides TextReader.Read.

This method returns an integer so that it can return -1 if the end of the stream has been reached. If you manipulate the position of the underlying stream after reading data into the buffer, the position of the underlying stream might not match the position of the internal buffer. To reset the internal buffer, call the StreamReader.DiscardBufferedData method; however, this method slows performance and should be called only when absolutely necessary.

For a list of common I/O tasks, see Common I/O Tasks.

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0