gpt4 book ai didi

c# - 如何编码双指针?

转载 作者:太空宇宙 更新时间:2023-11-04 03:53:58 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com