Mono Class Library: System.IO.MemoryStream Overview | Members

System.IO.MemoryStream Constructor

Constructs and initializes a new non-resizable instance of the System.IO.MemoryStream class. [Edit]

public MemoryStream (byte[] buffer, int index, int count)

Parameters

buffer
The byte array from which to create the new stream. [Edit]
index
A int that specifies the index into buffer at which the stream begins. [Edit]
count
A int that specifies the length of the stream in bytes. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionbuffer is null. [Edit]
ArgumentOutOfRangeExceptionindex or count is less than zero. [Edit]
ArgumentException(index + count ) is greater than the length of buffer. [Edit]

Remarks

The Stream.CanRead, Stream.CanSeek, and Stream.CanWrite properties of the new System.IO.MemoryStream instance are set to true. The MemoryStream.Capacity property is set to count .

Note: The new stream instance can be written to, but the MemoryStream.Capacity of the underlying byte array cannot be changed. The length of the stream cannot be set to a value larger than MemoryStream.Capacity, but the stream can be truncated (see MemoryStream.SetLength(long)).

The new stream does not expose the underlying byte buffer, and calls to the MemoryStream.GetBuffer method throw UnauthorizedAccessException .

[Edit]

Requirements

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