public WriteBytes ( IByteBuffer source ) : void | ||
source | IByteBuffer | The bytes (in the form of an IByteBuffer). |
리턴 | void |
public void TestWriteTo() { var backingBytes = new byte[100]; using (var buffer = new ByteArrayBuffer(backingBytes, 10, 80, false)) { buffer.WriteBytes(0, new[] { (byte)1, (byte)2 }, 0, 2); buffer.Length = 2; using (var memoryStream = new MemoryStream()) { buffer.WriteTo(memoryStream); Assert.AreEqual(2, memoryStream.Length); } } }
public void TestWriteBytes() { var bytes = new[] { (byte)1, (byte)2 }; var backingBytes = new byte[100]; using (var buffer = new ByteArrayBuffer(backingBytes, 10, 80, false)) { Assert.AreEqual(0, backingBytes[30]); Assert.AreEqual(0, backingBytes[31]); Assert.AreEqual(0, backingBytes[32]); buffer.WriteBytes(20, bytes, 0, bytes.Length); Assert.AreEqual(1, backingBytes[30]); Assert.AreEqual(2, backingBytes[31]); Assert.AreEqual(0, backingBytes[32]); } }
public void TestWriteBytes() { var bytes = new[] { (byte)1, (byte)2 }; var backingBytes = new byte[100]; using (var buffer = new ByteArrayBuffer(backingBytes, 0, 0, false)) { Assert.AreEqual(0, backingBytes[0]); Assert.AreEqual(0, backingBytes[1]); Assert.AreEqual(0, backingBytes[2]); buffer.WriteBytes(bytes); Assert.AreEqual(1, backingBytes[0]); Assert.AreEqual(2, backingBytes[1]); Assert.AreEqual(0, backingBytes[2]); Assert.AreEqual(2, buffer.Position); Assert.AreEqual(2, buffer.Length); } }