小编Sab*_*kar的帖子

如何将 IntPtr 转换为数组?

如何将 转换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); 
Run Code Online (Sandbox Code Playgroud)

调用函数

void Function1()
{
     IntPtr PPtr=N_AllocPt1dArray(n, ref S);
}
Run Code Online (Sandbox Code Playgroud)

现在我需要转换PPtr为数组(数组是demo[])。其中 demo 是由

public unsafe struct demo 
{            
    public int x ;
    public int y ;
    public int z ;
}demo DEMO;
Run Code Online (Sandbox Code Playgroud)

c#

5
推荐指数
1
解决办法
4392
查看次数

标签 统计

c# ×1