发布网友
共2个回答
热心网友
看你的定义里有数组,有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;
};
-手写的,仅供参考
热心网友
在Visual C++里添加如下程序:
struct A
{
int a;
struct B * b;
};
struct B
{
int b;
struct A * a;
};
struct C
{
int c;
struct B * b;
struct A * a;
};
..........