C#元帅数组的结构与C dll中的数组

时间:2019-03-13 22:35:34

标签: c# c arrays marshalling

在C library.dll 中定义了函数 GetList 。 作为参数,我们将列表ID放入变量 nr 。 函数调用返回列表中的条目数,并在列表中列出自身 变量 outlist

extern "C" 
{
  typedef struct
  {
    char name[8];
    int number;
  } ListEntry;

  typedef ListEntry List[16];

  extern int GetList(int *nr, List outlist);
}
C中的

用法如下:

int id = 1;
List outlist;
int count;

count = GetList(&id, &outlist);
for (i = 0; i < count; i++)
{
  fprintf(stdout,"Name: <%8.8s> -- Number: <%2d>\n", outlist[i].name, outlist[i].number);
}

我在这里找到了一些帮助-它涵盖了用数组封送结构

Marshalling C struct containing arrays to C#

我必须用数组封送结构数组。我在这方面是新手,不知道如何做。

谢谢您的帮助。

0 个答案:

没有答案
相关问题