Initializes a new MemoryStream based on the specified region (index) of a byte array.
[Visual Basic] Overloads Public Sub New( _ ByVal buffer() As Byte, _ ByVal index As Integer, _ ByVal count As Integer _ ) [C#] public MemoryStream( byte[] buffer, int index, int count ); [C++] public: MemoryStream( unsigned char* buffer[], int index, int count ); [JScript] public function MemoryStream( buffer : Byte[], index : int, count : int );
Exception Type | Condition |
---|---|
ArgumentNullException | buffer is null. |
ArgumentOutOfRangeException | index or count is less than zero. |
ArgumentException | The sum of index and count is greater than the length of buffer. |
The CanRead, CanSeek, and CanWrite properties are all set to true, but the capacity cannot be changed.
The length of the stream cannot be set to a value greater than the initial length of the specified byte array; however, the stream can be truncated (see SetLength).
This constructor does not expose the underlying stream. GetBuffer throws AccessException. However, the stream is writeable.
MemoryStream Class | MemoryStream Members | System.IO Namespace | MemoryStream Constructor Overload List