作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何转换IntPtr
到一个数组。实际上我从非托管 dll 调用了该函数。它返回 IntPtr
.现在我需要将其转换为数组。请任何人给出一个想法。代码片段如下。
Unmanaged function declared
[DllImport("NLib.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe IntPtr N_AllocPt1dArray(NL_INDEX n, ref stacks S);
void Function1()
{
IntPtr PPtr=N_AllocPt1dArray(n, ref S);
}
PPtr
到一个数组(数组是
demo[]
),其中演示由
public unsafe struct demo
{
public int x ;
public int y ;
public int z ;
}demo DEMO;
最佳答案
尝试这个:
array[0] = (demo)System.Runtime.InteropServices.Marshal.PtrToStructure(PPtr , typeof(demo));
关于c# - 如何将 IntPtr 转换为数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31854195/
我是一名优秀的程序员,十分优秀!