March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System; using System.IO; namespace Samples { public class MemoryStreamSample { public static void Main() { byte[] bytes = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; using(MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length)) { DisplayInformationAboutStream(ms); bytes = new Byte[5]; ms.Read(bytes, 0, bytes.Length); foreach(Byte b in bytes) Console.WriteLine(b); } using(MemoryStream ms = new MemoryStream(256)) { ms.SetLength(10); DisplayInformationAboutStream(ms); byte[] bytes1 = ms.GetBuffer(); ms.SetLength(1024); DisplayInformationAboutStream(ms); Byte[] bytes2 = ms.GetBuffer(); Console.WriteLine("Are the buffers the same: {0}", Object.ReferenceEquals(bytes1, bytes2)); } } public static void DisplayInformationAboutStream( MemoryStream ...Read now
Unlock full access