RecyclableMemoryStream.SafeRead method (1 of 2)

December 6, 2023 · View on GitHub

Reads from the specified position into the provided buffer.

public int SafeRead(Span<byte> buffer, ref long streamPosition)
parameterdescription
bufferDestination buffer.
streamPositionPosition in the stream to start reading from.

Return Value

The number of bytes read.

Exceptions

exceptioncondition
ObjectDisposedExceptionObject has been disposed.

See Also


RecyclableMemoryStream.SafeRead method (2 of 2)

Reads from the specified position into the provided buffer.

public int SafeRead(byte[] buffer, int offset, int count, ref long streamPosition)
parameterdescription
bufferDestination buffer.
offsetOffset into buffer at which to start placing the read bytes.
countNumber of bytes to read.
streamPositionPosition in the stream to start reading from.

Return Value

The number of bytes read.

Exceptions

exceptioncondition
ArgumentNullExceptionbuffer is null.
ArgumentOutOfRangeExceptionoffset or count is less than 0.
ArgumentExceptionoffset subtracted from the buffer length is less than count.
ObjectDisposedExceptionObject has been disposed.

See Also