C# MemoryStream MemoryStream(Byte[], Int32, Int32, Boolean)

Description

MemoryStream MemoryStream(Byte[], Int32, Int32, Boolean) 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.

Syntax

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


public MemoryStream(
  byte[] buffer,/*  w  w w.j  a  v a  2 s.  c  om*/
  int index,
  int count,
  bool writable
)

Parameters

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

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

Example


using System.IO;/*from   w ww.  j  a v a  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},0,1,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