看你的定义里有数组,有Struct嵌套,给你的例子参考:C++: typedef struct{
BYTE ByteV[10];
} StructA;
typedef struct
{
BYTE ByteV[10];
StructA StructAs[20];
} StructB;
C#: [StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct StructA
{
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=10)]
public byte[] ByteV;
};
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
public struct StructB
{
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=10)]
public byte[] ByteV;
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=20)]
public StructA[] StructAs;
};
-手写的,仅供参考