38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
namespace CommonConsole
|
|
{
|
|
using System;
|
|
|
|
public class Program
|
|
{
|
|
public static void Main()
|
|
{
|
|
var bytes = new Byte[] { 0x00, 0x00, 0x00, 0x05 };
|
|
|
|
var index = 0;
|
|
var valueMSB = 0;
|
|
|
|
valueMSB ^= bytes[index++] << 24;
|
|
valueMSB ^= bytes[index++] << 16;
|
|
valueMSB ^= bytes[index++] << 08;
|
|
valueMSB ^= bytes[index++] << 00;
|
|
|
|
index = 3;
|
|
var valueLSB = 0;
|
|
|
|
valueLSB ^= bytes[index--] << 24;
|
|
valueLSB ^= bytes[index--] << 16;
|
|
valueLSB ^= bytes[index--] << 08;
|
|
valueLSB ^= bytes[index--] << 00;
|
|
|
|
Console.WriteLine($"{nameof(valueMSB)} == {nameof(valueLSB)} => {valueMSB} == {valueLSB} = {valueMSB == valueLSB}");
|
|
|
|
var _lsb = BitConverter.ToInt32(bytes, 0);
|
|
|
|
Array.Reverse(bytes);
|
|
|
|
var _msb = BitConverter.ToInt32(bytes, 0);
|
|
|
|
Console.WriteLine($"{nameof(_msb)} == {nameof(_lsb)} => {_msb} == {_lsb} = {_msb == _lsb}");
|
|
}
|
|
}
|
|
} |