C# MemoryStream Capacity

Description

MemoryStream Capacity Gets or sets the number of bytes allocated for this stream.

Syntax

MemoryStream.Capacity has the following syntax.


public virtual int Capacity { get; set; }

Example


using System;// w  ww  . j av  a 2 s  .  c om
using System.IO;
public class MainClass{
  public static void Main(String[] argv){  
    MemoryStream memStream = new MemoryStream();
    
    Console.WriteLine("Capacity = {0}, Length = {1}, Position = {2}\n",
        memStream.Capacity.ToString(),
        memStream.Length.ToString(),
        memStream.Position.ToString());
    
  }
}

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