我正在尝试使用 pinvoke 将 C 结构编码到 C#。虽然我能够编码一个 intptr,但我找不到编码双指针的语法。 C 端使用 int 指针和 double 指针来分配一个 int 或 double 数组。
这是 C 结构体:
struct xyz
{
int *np; // an int pointer works fine
double *foo;
};
这是 C# 类:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class xyz
{
Intptr np; // works fine
// double *foo ??
}
我找不到任何关于如何标记的说明
最佳答案
查看 this description for what an IntPtr is .您是否尝试过使用:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class xyz
{
IntPtr np;
IntPtr foo;
}
关于c# - 如何编码双指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18592138/