Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

MemoryStream Constructor

.NET Framework 1.1

Initializes a new instance of the MemoryStream class.

Overload List

Initializes a new instance of the MemoryStream class with an expandable capacity initialized to zero.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New()
[C#] public MemoryStream();
[C++] public: MemoryStream();
[JScript] public function MemoryStream();

Initializes a new non-resizable instance of the MemoryStream class based on the specified byte array.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(Byte())
[C#] public MemoryStream(byte[]);
[C++] public: MemoryStream(unsigned char __gc[]);
[JScript] public function MemoryStream(Byte[]);

Initializes a new instance of the MemoryStream class with an expandable capacity initialized as specified.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(Integer)
[C#] public MemoryStream(int);
[C++] public: MemoryStream(int);
[JScript] public function MemoryStream(int);

Initializes a new non-resizable instance of the MemoryStream class based on the specified byte array with the CanWrite property set as specified.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(Byte(), Boolean)
[C#] public MemoryStream(byte[], bool);
[C++] public: MemoryStream(unsigned char __gc[], bool);
[JScript] public function MemoryStream(Byte[], Boolean);

Initializes a new non-resizable instance of the MemoryStream class based on the specified region (index) of a byte array.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(Byte(), Integer, Integer)
[C#] public MemoryStream(byte[], int, int);
[C++] public: MemoryStream(unsigned char __gc[], int, int);
[JScript] public function MemoryStream(Byte[], int, int);

Initializes a new non-resizable instance of the MemoryStream class based on the specified region of a byte array, with the CanWrite property set as specified.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(Byte(), Integer, Integer, Boolean)
[C#] public MemoryStream(byte[], int, int, bool);
[C++] public: MemoryStream(unsigned char __gc[], int, int, bool);
[JScript] public function MemoryStream(Byte[], int, int, Boolean);

Initializes a new instance of the MemoryStream class based on the specified region of a byte array, with the CanWrite property set as specified, and the ability to call GetBuffer set as specified.

Supported by the .NET Compact Framework.

[Visual Basic] Public Sub New(Byte(), Integer, Integer, Boolean, Boolean)
[C#] public MemoryStream(byte[], int, int, bool, bool);
[C++] public: MemoryStream(unsigned char __gc[], int, int, bool, bool);
[JScript] public function MemoryStream(Byte[], int, int, Boolean, Boolean);

Example

[Visual Basic, C#, C++] This code example is part of a larger example provided for the MemoryStream class.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the MemoryStream constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Dim memStream As New MemoryStream(100)

[C#] 
using(MemoryStream memStream = new MemoryStream(100))

[C++] 
MemoryStream* memStream = new MemoryStream(100);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

MemoryStream Class | MemoryStream Members | System.IO Namespace

Show:
© 2015 Microsoft