[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi, Pack = 1)]
public struct strUion
{
[FieldOffset(0)]
public ushort crc16;
[FieldOffset(0)]
public byte crc16L;
[FieldOffset(1)]
public byte crc16H;
public strUion(ushort _crc16)
{
crc16 = _crc16;
crc16H = 0;
crc16L = 0;
}
}
class Program
{
static void Main(string[] args)
{
strUion su = new strUion(0);
su.crc16 = 0x0102;
Console.WriteLine(su.crc16H.ToString("X2") + " " + su.crc16L.ToString("X2"));
Console.ReadLine();
}
}