Visual Basic (Declaration) | |
---|---|
Public Class SegmentedMemoryStream Inherits System.IO.Stream |
C# | |
---|---|
public class SegmentedMemoryStream : System.IO.Stream |
Library/Library.Test/TestSegmentedStream.cs
C# | Copy Code |
---|---|
using (SegmentedMemoryStream ms = new SegmentedMemoryStream(5)) { Write(ms, "12345"); Write(ms, "abcd"); Write(ms, "ABCDEF"); Write(ms, "12345"); Write(ms, ""); ms.Flush(); Assert.AreEqual(20L, ms.Length); Assert.AreEqual(20L, ms.Position); ms.Position = 0; Assert.AreEqual("12345abcdABCDEF12345", Read(ms, (int)ms.Length)); ms.Position = 5; Assert.AreEqual("a", Read(ms, 1)); Assert.AreEqual("bcd", Read(ms, 3)); Assert.AreEqual("ABCDEF", Read(ms, 6)); Assert.AreEqual("12345", Read(ms, 5)); Assert.AreEqual(0, ms.Read(new byte[10], 0, 10)); } |
VB.NET | Copy Code |
---|---|
Using ms As New SegmentedMemoryStream(5) Write(ms, "12345") Write(ms, "abcd") Write(ms, "ABCDEF") Write(ms, "12345") Write(ms, "") ms.Flush() Assert.AreEqual(20L, ms.Length) Assert.AreEqual(20L, ms.Position) ms.Position = 0 Assert.AreEqual("12345abcdABCDEF12345", Read(ms, DirectCast(ms.Length, Integer))) ms.Position = 5 Assert.AreEqual("a", Read(ms, 1)) Assert.AreEqual("bcd", Read(ms, 3)) Assert.AreEqual("ABCDEF", Read(ms, 6)) Assert.AreEqual("12345", Read(ms, 5)) Assert.AreEqual(0, ms.Read(New Byte(10) {}, 0, 10)) End Using |
System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.SegmentedMemoryStream
CSharpTest.Net.IO.SharedMemoryStream
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7