c# - 如何编码双指针?

标签 c# c pointers pinvoke marshalling

我正在尝试使用 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/

相关文章:

c - 如何将指针数组引用到多个常量数组

c# - 检查机器上的第三方防火墙

c - 在 C 中使用 getchar() 将输入发送到 char 数组

c# - 从 C# 中读取 XML

c++ - 在包裹的命令行中//之后解开空间

C: 在特定内存位置访问 'char'?

c++ - 涉及指针和手动实现的矩阵类的问题

C++在不知道大小的情况下越界时检测悬挂指针

c# - 在c#中使用openxml和pdfcreator将docx转换为pdf

c# - 从 temp 获取真实文件名