public static byte[] ToByteArray(RpcPacketHeader header) { byte[] buffer = new byte[Size]; IntPtr structPtr = Marshal.AllocHGlobal(Size); Marshal.StructureToPtr(header, structPtr, true); Marshal.Copy(structPtr, buffer, 0, Size); Marshal.FreeHGlobal(structPtr); return buffer; }
public static byte[] ToByteArray(RpcPacketHeader header) { byte[] buffer = new byte[Size]; IntPtr structPtr = Marshal.AllocHGlobal(Size); Marshal.StructureToPtr(header, structPtr, true); Marshal.Copy(structPtr, buffer, 0, Size); Marshal.FreeHGlobal(structPtr); return(buffer); }