C# MemoryStream Length

Description

MemoryStream Length Gets the length of the stream in bytes.

Syntax

MemoryStream.Length has the following syntax.


public override long Length { get; }

Example


//from  w w w .j  ava  2 s.c om
using System;
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