NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

MemoryStream.Read

Reads a block of bytes from the current stream and writes the data to buffer.

[Visual Basic]
Overrides Public Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
[C#]
public override int Read(
   byte[] buffer,
   int offset,
   int count
);
[C++]
public: override int Read(
   unsigned char* buffer[],
   int offset,
   int count
);
[JScript]
public override function Read(
   buffer : Byte[],
   offset : int,
   count : int
) : int;

Parameters

buffer
The byte array to read into.
offset
The byte offset at which to begin writing.
count
The maximum number of bytes to read.

Return Value

The total number of bytes read into the buffer. This may be less than the number of bytes requested if that many bytes aren't currently available, or zero if the end of the stream is reached.

Exceptions

Exception Type Condition
ArgumentNullException buffer is null.
ArgumentOutOfRangeException offset or count is negative.
ArgumentException offset subtracted from the buffer length is less than count.

Remarks

The offset parameter gives the offset of the first byte in buffer to which data from the current stream is written. The count parameter gives the maximum number of bytes to read from the current stream. The returned value is the actual number of bytes read, or zero if the end of the stream is reached.

If the read operation is successful, the current position within the stream is advanced by the number of bytes read. If an exception occurs, the current position within the stream is unchanged.

The Read method will return zero 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. If no data is available from the stream upon a call to Read, the method will block until at least 1 byte of data can be returned.

See Also

MemoryStream Class | MemoryStream Members | System.IO Namespace