使用DllImport时,在C#中包装C ++参考参数

|| 我正在尝试使用C#代码包装具有参考参数的C ++函数。 我的C#包装器类有
[DllImport(TestCppDLL.dll)]
public static extern void foo(out int a, out int b, out double c);

public void main()
{
    int a;
    int b;
    double c;

    this.foo(out a, out b, out c);
    Console.WriteLine(a + b + c);
}
我的C ++代码是
extern void foo(int &a, int &b, double &c)
{
     a = 1;
     b = 2;
     c = 3;
}
因此,我希望输出为\“ 123 \”,但得到\“ 000 \”。 如何包装C ++参考参数? 先感谢您,     
已邀请:
您的C ++代码返回一个double,但是您的C#代码将函数声明为具有空返回值。 您可能还会遇到呼叫约定不匹配的情况。 C ++默认为cdecl,C#默认为stdcall。 否则就可以了。     

要回复问题请先登录注册