我试图编组以下结构:
[StructLayout(LayoutKind.Sequential)]
public struct LogonTelegramStruct
{
[MarshalAs(UnmanagedType.I2)]
public ushort length;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)]
public string name;
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.ByValTStr,
Size = (length-21)/5 )]
public string[] points;
}
如何编组点数组?单个点的长度始终为5个字节。长度字段给出结构其余部分的长度。因此,点阵列大小为(长度-21)/ 5。是否有可能在没有遍历每个点的情况下编组?