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

Description

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

Syntax

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


public MemoryStream(
  byte[] buffer,/*  w  w w  .  ja va2s.c om*/
  int index,
  int count,
  bool writable,
  bool publiclyVisible
)

Parameters

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

  • buffer - The array of unsigned bytes from which to create this stream.
  • index - The index into 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.
  • publiclyVisible - true to enable GetBuffer, which returns the unsigned byte array from which the stream was created; otherwise, false.

Example


using System.IO;//  www.j a  va 2s . 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,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