System.IO.BufferedStream.Read Method

Copies bytes from the current buffered stream to an array.

Syntax

public override int Read (byte[] array, int offset, int count)

Parameters

array
The buffer to which bytes are to be copied.
offset
The byte offset in the buffer at which to begin reading bytes.
count
The number of bytes to be read.

Returns

The total number of bytes read into array. This can be less than the number of bytes requested if that many bytes are not currently available, or 0 if the end of the stream has been reached before any data can be read.

Remarks

The Read method will return 0 only if the end of the stream is reached. In all other cases, Read always reads at least one byte from the stream before returning. By definition, if no data is available from the stream upon a call to Read, the Read method returns 0 (the end of the stream is reached automatically). An implementation is free to return fewer bytes than requested even if the end of the stream has not been reached.

Use System.IO.BinaryReader for reading primitive data types.

Requirements

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