在 CPP 项目 (MathFuncsDll.h) 中使用此示例代码行
extern "C" __declspec(dllexport) double Add(double a, double b);
extern "C" __declspec(dllexport) double Sub(double a, double b);
extern "C" __declspec(dllexport) double Mul(double a, double b);
extern "C" __declspec(dllexport) double Div(double a, double b);
在 C# 代码中这样使用
[DllImport("MathFuncs.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern Double Add(Double a, Double b);
[DllImport("MathFuncs.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern Double Mul(Double a, Double b);
[DllImport("MathFuncs.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern Double Sub(Double a, Double b);
[DllImport("MathFuncs.dll",CallingConvention = CallingConvention.Cdecl)]
public static extern Double Div(Double a, Double b);
[DllImport("MathFuncs.dll",CallingConvention = CallingConvention.Cdecl)]
public static extern Double Bat(Double a, Double b);