You are probably going to need to use unsafe
with fixed size buffers here.
unsafe struct MMTPRcnxReq
{
public int Port;
public fixed byte SubsId[FIELD_SIZE_SUBS_ID+1];
public fixed byte Options[FIELD_SIZE_OPTIONS+1];
}
The fixed size buffer is a value type, and that will allow you to put one of these structs inside a FieldOffset(0)
C# union.
Read the strings like this:
string SubsId;
unsafe
{
fixed (byte* ptr = req.SubsId)
{
// I presume that req.SubsId is null-terminated
SubsId = Marshal.PtrToStringAnsi((IntPtr)ptr);
}
}
You would probably write helper getter and setter methods of the struct, perhaps as properties, to manage the fixed size buffers.