Create a memorystream in csharp

using System;
using System.IO;
 
 
class MemStreamApp
{
    static void Main(string[] args)
    {
        MemoryStream m = new MemoryStream(64);
        Console.WriteLine("Length: {0}\tPosition: {1}\tCapacity: {2}",m.Length, m.Position, m.Capacity);
 
        for (int i = 0; i < 64; i++)
        {
            m.WriteByte((byte)i);
        }
        Console.WriteLine("Length: {0}\tPosition: {1}\tCapacity: {2}",m.Length, m.Position, m.Capacity);
 
        byte[] ba = m.GetBuffer();
        foreach (byte b in ba)
        {
            Console.Write("{0,-3}", b);
        }
 
        m.Close();
    }
}
Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

 

 
eXTReMe Tracker