System.IO.Stream.ReadByte Method

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Syntax

public virtual int ReadByte ()

Returns

The unsigned byte cast to an Int32, or -1 if at the end of the stream.

Exceptions

TypeReason
System.IO.IOExceptionAn I/O error has occurred.
NotSupportedExceptionThe stream does not support reading.
ObjectDisposedExceptionThe stream is closed.

Remarks

Use the Stream.CanRead property to determine whether the current instance supports reading.

Attempts to manipulate the stream after the stream has been closed could throw an ObjectDisposedException.

Requirements

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