public void ReadDoubleWord() { var arr = new byte[] { 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0 }; ulong v = BufferMarshal.GetFromBuffer(arr, 1, 8); Assert.AreEqual((ulong)0x01_02_03_04_05_06_07_08, v); }
public void ReadHalfWord() { var arr = new byte[] { 0, 0x01, 0x02, 0 }; ushort v = (ushort)BufferMarshal.GetFromBuffer(arr, 1, 2); Assert.AreEqual((ushort)0x01_02, v); }
public void ReadWord() { var arr = new byte[] { 0, 0x01, 0x02, 0x03, 0x04, 0 }; uint v = (uint)BufferMarshal.GetFromBuffer(arr, 1, 4); Assert.AreEqual((uint)0x01_02_03_04, v); }
public void ReadByte() { var arr = new byte[] { 0, 0x01, 0 }; byte v = (byte)BufferMarshal.GetFromBuffer(arr, 1, 1); Assert.AreEqual(0x01, v); }