Is there a way to ignore a field in the calculated of the struct size using Marshal.SizeOf
Ex:
public struct Message
{
public ushort X;
public ushort Y; // Ignore this field in the calculation
}
int size = Marshal.SizeOf(typeof(Message));
Right now size is 4. I want the size to be 2. Is there a way to do this?