Export (0) Print
Expand All

StreamReader.Read Method

Updated: December 2010

When it is called by trusted applications, reads the next character from the input stream and advances the character position by one character.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

public override int Read()

Return Value

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

ExceptionCondition
IOException

An I/O error occurs.

This method overrides 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 DiscardBufferedData method; however, this method slows performance and should be called only when absolutely necessary.

Platform Notes

Silverlight for Windows Phone Silverlight for Windows Phone

 StreamReader.Read may throw IndexOutOfRangeException if the stream state becomes corrupted. On Silverlight for Windows Phone, the stream state may become corrupted if multiple threads read from or write to a stream object without using synchronization.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Date

History

Reason

December 2010

Added information about calling DiscardBufferedData.

Information enhancement.

Community Additions

ADD
Show:
© 2015 Microsoft