当前位置: 首页>>代码示例>>C#>>正文


C# ChunkedMemoryStream.ToArray方法代码示例

本文整理汇总了C#中ChunkedMemoryStream.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# ChunkedMemoryStream.ToArray方法的具体用法?C# ChunkedMemoryStream.ToArray怎么用?C# ChunkedMemoryStream.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ChunkedMemoryStream的用法示例。


在下文中一共展示了ChunkedMemoryStream.ToArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestWriteByte

        public void TestWriteByte()
        {
            using (var stream = new ChunkedMemoryStream(8)) {
            Assert.AreEqual(0L, stream.Position);
            Assert.AreEqual(0L, stream.Length);

            for (var i = 0; i < 32; i++) {
              Assert.AreEqual((long)i, stream.Position);

              stream.WriteByte((byte)i);

              Assert.AreEqual((long)(i + 1), stream.Position);
              Assert.AreEqual((long)(i + 1), stream.Length);
            }

            Assert.AreEqual(new byte[] {
              0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
              0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
            }, stream.ToArray());
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:21,代码来源:ChunkedMemoryStream.cs

示例2: TestWrite

        public void TestWrite()
        {
            using (var stream = new ChunkedMemoryStream(8)) {
            Assert.AreEqual(0L, stream.Position);
            Assert.AreEqual(0L, stream.Length);

            stream.Write(new byte[] {0x00}, 0, 1);
            Assert.AreEqual(1L, stream.Position);
            Assert.AreEqual(1L, stream.Length);

            stream.Write(new byte[] {0x01, 0x02, 0x03}, 0, 3);
            Assert.AreEqual(4L, stream.Position);
            Assert.AreEqual(4L, stream.Length);

            stream.Write(new byte[] {0x04, 0x05, 0x06, 0x07}, 0, 4);
            Assert.AreEqual(8L, stream.Position);
            Assert.AreEqual(8L, stream.Length);

            stream.Write(new byte[] {0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e}, 0, 7);
            Assert.AreEqual(15L, stream.Position);
            Assert.AreEqual(15L, stream.Length);

            stream.Write(new byte[] {0x0f, 0x10}, 0, 2);
            Assert.AreEqual(17L, stream.Position);
            Assert.AreEqual(17L, stream.Length);

            stream.Write(new byte[] {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}, 0, 15);
            Assert.AreEqual(32L, stream.Position);
            Assert.AreEqual(32L, stream.Length);

            Assert.AreEqual(new byte[] {
              0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
              0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
            }, stream.ToArray());
              }
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:36,代码来源:ChunkedMemoryStream.cs


注:本文中的ChunkedMemoryStream.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。