从C#包装器函数调用非托管代码 [英] Calling unmanaged code from C# wrapper function

查看:75
本文介绍了从C#包装器函数调用非托管代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过C#应用程序的CLR方法访问我的C ++ API。



C ++方法: int CreateEntity(double * Points) ;

等效CLR包装方法: int CreateEntity(双倍积分);



我需要填写一个C#app中的双精度数并传递CLR方法。

XML样本中的双精度列表

I need to access my C++ API via CLR method from C# application.

C++ method:int CreateEntity(double* Points);
Equivalent CLR wrapper method: int CreateEntity(double% Points);

I need to fill a number of doubles in C# app and pass it CLR method.
A list of doubles from a XML sample

<pts>0.0000000000000000,36.6508338286590030,73.3016676573180060,109.9525014859799900,146.6033353146399900</pts>







string[] vals = Values.Split(',');
double[] DVal = new double[size];
for (int itr = 0; itr < size; itr++)
     DVal[itr] = Convert.ToDouble(vals[itr]);

Object.CreateEntity(DVal); // Error CS1503





获取错误错误CS1503:参数3:无法从'ref double *'转换为'ref double'



需要建议。在此先感谢。



Getting the error "error CS1503: Argument 3: cannot convert from 'ref double*' to 'ref double'"

Suggestions needed. Thanks in advance.

推荐答案

参见使用ref和out(C#)传递数组 [ ^ ]。


这篇关于从C#包装器函数调用非托管代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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