C# MemoryStream Write

Description

MemoryStream Write Writes a block of bytes to the current stream using data read from a buffer.

Syntax

MemoryStream.Write has the following syntax.


public override void Write(
  byte[] buffer,//from  www  .  j a v a  2  s  . c  om
  int offset,
  int count
)

Parameters

MemoryStream.Write has the following parameters.

  • buffer - The buffer to write data from.
  • offset - The zero-based byte offset in buffer at which to begin copying bytes to the current stream.
  • count - The maximum number of bytes to write.

Returns

MemoryStream.Write method returns

Example


// w w  w .j a v  a  2  s. c  o m
using System.IO;
using System;
public class MainClass{
  public static void Main(String[] argv){  
    MemoryStream memStream = new MemoryStream();
    memStream.Write(new byte[]{1,2,3},0, 2);
    
  }
}




















Home »
  C# Tutorial »
    System.IO »




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