本文整理汇总了C#中Span.ReadLittleEndian方法的典型用法代码示例。如果您正苦于以下问题:C# Span.ReadLittleEndian方法的具体用法?C# Span.ReadLittleEndian怎么用?C# Span.ReadLittleEndian使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Span
的用法示例。
在下文中一共展示了Span.ReadLittleEndian方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BufferReaderRead
public void BufferReaderRead()
{
Assert.True(BitConverter.IsLittleEndian);
ulong value = 0x8877665544332211; // [11 22 33 44 55 66 77 88]
Span<byte> span;
unsafe {
span = new Span<byte>(&value, 8);
}
Assert.Equal<byte>(0x11, span.ReadBigEndian<byte>());
Assert.Equal<byte>(0x11, span.ReadLittleEndian<byte>());
Assert.Equal<sbyte>(0x11, span.ReadBigEndian<sbyte>());
Assert.Equal<sbyte>(0x11, span.ReadLittleEndian<sbyte>());
Assert.Equal<ushort>(0x1122, span.ReadBigEndian<ushort>());
Assert.Equal<ushort>(0x2211, span.ReadLittleEndian<ushort>());
Assert.Equal<short>(0x1122, span.ReadBigEndian<short>());
Assert.Equal<short>(0x2211, span.ReadLittleEndian<short>());
Assert.Equal<uint>(0x11223344, span.ReadBigEndian<uint>());
Assert.Equal<uint>(0x44332211, span.ReadLittleEndian<uint>());
Assert.Equal<int>(0x11223344, span.ReadBigEndian<int>());
Assert.Equal<int>(0x44332211, span.ReadLittleEndian<int>());
Assert.Equal<ulong>(0x1122334455667788, span.ReadBigEndian<ulong>());
Assert.Equal<ulong>(0x8877665544332211, span.ReadLittleEndian<ulong>());
Assert.Equal<long>(0x1122334455667788, span.ReadBigEndian<long>());
Assert.Equal<long>(unchecked((long)0x8877665544332211), span.ReadLittleEndian<long>());
}