双打元帅数组从C到C# [英] Marshal array of doubles from c to c#

查看:182
本文介绍了双打元帅数组从C到C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我什么我应该写名帅之间的C和C#?

Can someone please tell me exactly what I should write to marshal an array of double pointers between C and C#?

struct foo { double *abc[20]; };

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class foo {  // ??? abc;   }

我有许多斜resonses 2 previous查询,我对这个同一主题在这里找到另一十几个问题,但我不能在其中任何一个简单的回答这个问题找到。

I have had many oblique resonses to 2 previous queries, and I have read another dozen or so questions here on this same topic, but I can't find in any of them a simple answer to this question.

推荐答案

好吧,这里是简单,直接回答这个问题:

Ok, here is the simple, straightforward answer to this question:

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
public IntPtr[] abc;

诀窍是,直觉相反,您必须尽管这是双数组的指针,不是int指针使用一个IntPtr。

The trick is that, counterintuitively, you must use an IntPtr despite the fact this is an array of double pointers, not int pointers.

这篇关于双打元帅数组从C到C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆