C#如何调用这个DLL函数

2025-04-13 03:02:14
推荐回答(2个)
回答1:

//声明
[DllImport("fun.dll", EntryPoint = "mfun")]
public static extern void mfun(double[] a, double[] b);
//调用部分
//先为两个变量分配空间,根据自己的实际需要分配
double[] a = new double[10];
double[] b = new double[10];
//调用函数,因为数组是引用类型,所以不用ref或out关键字。如果是值类型就要使用ref/out,不然值是传不出来的
mfun( a, b);

回答2:

[System.Runtime.InteropServices.DllImportAttribute("", EntryPoint="mfun")]
public static extern void mfun(ref double x, ref double y) ;