public byte[] Serialize()
{
byte[] resultBytes = new byte[Marshal.SizeOf(this)];
IntPtr ptr = new IntPtr();
ptr = Marshal.AllocHGlobal(Marshal.SizeOf(this));
try
{
Marshal.StructureToPtr(this, ptr, true);
Marshal.Copy(ptr, resultBytes, 0, Marshal.SizeOf(this));
return resultBytes;
}
finally
{
Marshal.FreeHGlobal(ptr);
}
}