C# MemoryStream MemoryStream(Byte[], Boolean)

Description

MemoryStream MemoryStream(Byte[], Boolean) Initializes a new non-resizable instance of the MemoryStream class based on the specified byte array with the CanWrite property set as specified.

Syntax

MemoryStream.MemoryStream(Byte[], Boolean) has the following syntax.


public MemoryStream(
  byte[] buffer,
  bool writable
)

Parameters

MemoryStream.MemoryStream(Byte[], Boolean) has the following parameters.

  • buffer - The array of unsigned bytes from which to create this stream.
  • writable - The setting of the CanWrite property, which determines whether the stream supports writing.

Example


using System.IO;/*from   w w w .ja va 2  s  . c  o m*/
using System;
public class MainClass{
  public static void Main(String[] argv){  
    MemoryStream ms = new MemoryStream(new byte[]{1,2,3},false);
    System.Console.WriteLine(ms.CanRead);
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter