Tuesday, September 7th, 2010

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

Readers Comments (0)




Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.


Latest Additions

Popular User Submitted Links

1


Hosted & Optimized JS Libraries – Cached Commons

1


Multi-File Uploader & Resizer – Agile Uploader

1


Open source online notebook-to-do-list manager

1


3 tier app design in silverlight using azure & RIA services

1


Polymaps – A JS Library For Image & Vector-Tiled Maps

eXTReMe Tracker