public static unsafe void Main (string[] args) { var bytes = new byte[20]; fixed (byte* pBytes = bytes) { var pStruct = (StructWithUInt64*)pBytes; *pStruct = new StructWithUInt64 { A = 0xAABBCCDD, B = 0x0011223344556677UL, C = 0xDDCCBBAA }; } Util.PrintBytes(bytes); }
public static unsafe void Main(string[] args) { var bytes = new byte[20]; fixed(byte *pBytes = bytes) { var pStruct = (StructWithUInt64 *)pBytes; *pStruct = new StructWithUInt64 { A = 0xAABBCCDD, B = 0x0011223344556677UL, C = 0xDDCCBBAA }; } Util.PrintBytes(bytes); }