基于以下C ++标题内容:
typedef struct {
char myVar[30][50];
}MyStruct;
extern "C" int WINAPI MyFunction(MyStruct *Configuration,int *CfgSize);
我在互联网上寻找了很多例子,但没有一个在 struct array 中使用矩阵变量作为参数。
有人可以告诉我如何在C#中使用这个功能吗?
答案 0 :(得分:1)
为了编组这个数组成员,你只需要将它展平为它所代表的1500个元素
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct MyStruct {
/// byte[1500]
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst=1500, ArraySubType=UnmanagedType.I1)]
public byte[] myVar;
}
确保在C#
中使用时手动初始化myVar
数组