如何在C#中编组结构数组?

我在C#中有以下结构:

[StructLayoutAttribute(LayoutKind.Sequential)] public struct RECORD { public uint m1; public uint m2; public uint m3; } 

我还需要将这些结构的数组 (固定长度)传递给本机代码,后者将一些数据写入这些结构。 该数组在C#中分配并传递给C dll。 我将导入的函数声明为:

 [DllImport("marshall.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void doIt(RECORD[] dataRecord); 

但我没有得到任何数据。 我已经尝试了PInvoke Interop助手。 我应该在这里使用IntPtr吗? 有任何想法吗?

编辑:

以下是调用本机函数的C#代码:

 RECORD[] rec = new RECORD[256]; doIt(rec); // values of rec are all zero here 

这是C函数:

 int doIt(RECORD* rec) { // deref pointer and write some data } 

我远不是P / Invoke专家,但我想知道是否将它作为输入/输出参数可能会有所帮助:

 DllImport("marshall.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void doIt([In, Out] RECORD[] dataRecord); 

我不会想到这是必要的,就像LayoutKind.Sequential我希望你的结构已经是一个blittable类型,并且数组也是blittable。