C++封装函数,输入参数 int a,double b,float ,返回值是float

C+代码

extern  "C" __declspec(dllexport) float Add(int a,double b,float c)
{
    return a + b + c;
}

 

C+代码

 [DllImport("ConsoleApplication1.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
 public static extern float Add(int a ,double b,float c);


//调用
 float d = Add(1, 2.5, 3.3f);
 MessageBox.Show($"Result: {d}");

 

posted @ 2026-05-30 11:01  家煜宝宝  阅读(10)  评论(0)    收藏  举报