當前位置: 首頁>>代碼示例>>C#>>正文


C# UInt16.SequenceEqual方法代碼示例

本文整理匯總了C#中System.UInt16.SequenceEqual方法的典型用法代碼示例。如果您正苦於以下問題:C# UInt16.SequenceEqual方法的具體用法?C# UInt16.SequenceEqual怎麽用?C# UInt16.SequenceEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.UInt16的用法示例。


在下文中一共展示了UInt16.SequenceEqual方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SerializeArrays

        public void SerializeArrays()
        {
            // Write data -------------------------------------
            var arrayUInt16 = new UInt16[] { 0, 900, 32000 };
           _serializer.Writer.WriteUInt16Array(arrayUInt16);
            AssertBytesWritten(8);

            var arrayUInt32 = new UInt32[] { 0, 900, 32000 };
           _serializer.Writer.WriteUInt32Array(arrayUInt32);
            AssertBytesWritten(14);

            var arrayInt16 = new Int16[] { -700, 0, 32000 };
           _serializer.Writer.WriteInt16Array(arrayInt16);
            AssertBytesWritten(8);

            var arrayInt32 = new Int32[] { -700, 0, 32000 };
           _serializer.Writer.WriteInt32Array(arrayInt32);
            AssertBytesWritten(14);

            var arrayInt64 = new Int64[] { -700, 0, 32000 };
           _serializer.Writer.WriteInt64Array(arrayInt64);
            AssertBytesWritten(26);

            _serializer.Writer.WriteUInt16Array(null); AssertBytesWritten(1);
            _serializer.Writer.WriteUInt32Array(null); AssertBytesWritten(1);
            _serializer.Writer.WriteInt16Array(null); AssertBytesWritten(1);
            _serializer.Writer.WriteInt32Array(null); AssertBytesWritten(1);
            _serializer.Writer.WriteInt64Array(null); AssertBytesWritten(1);


            // Message end
            _serializer.Writer.Internal.WriteDataUInt(Bms1Tag.MessageEnd, 0);
            AssertBytesWritten(1);

            // Read and verify data ----------------------------------------
            _stream.Position = 0;
            _serializer.Reader.Internal.ReadAttributes();

            Assert.IsTrue(arrayUInt16.SequenceEqual(_serializer.Reader.ReadUInt16Array()));
            Assert.IsTrue(arrayUInt32.SequenceEqual(_serializer.Reader.ReadUInt32Array()));
            Assert.IsTrue(arrayInt16.SequenceEqual(_serializer.Reader.ReadInt16Array()));
            Assert.IsTrue(arrayInt32.SequenceEqual(_serializer.Reader.ReadInt32Array()));
            Assert.IsTrue(arrayInt64.SequenceEqual(_serializer.Reader.ReadInt64Array()));

            Assert.IsNull(_serializer.Reader.ReadUInt16Array());
            Assert.IsNull(_serializer.Reader.ReadUInt32Array());
            Assert.IsNull(_serializer.Reader.ReadInt16Array());
            Assert.IsNull(_serializer.Reader.ReadInt32Array());
            Assert.IsNull(_serializer.Reader.ReadInt64Array());

            // Message end
            Assert.IsTrue(_serializer.Reader.Internal.EndOfBlock);
        }
開發者ID:steforster,項目名稱:Remact.Net.Bms1Serializer,代碼行數:53,代碼來源:ValueStreamTest.cs


注:本文中的System.UInt16.SequenceEqual方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。