using System;
using System.Runtime.InteropServices;
class Program
{
// 声明C++的函数,使用DllImport特性来指定DLL文件和调用约定
[DllImport("example.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int Add(int a, int b);
static void Main()
{
// 调用C++的Add函数
int result = Add(5, 3);
Console.WriteLine("The result is: " + result);
}
}
请确保你的C++代码已经编译成一个DLL,并且这个DLL位于你的应用程序可以访问的路径中。
上一篇:c#调用c++dll
下一篇:c c++ c#
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站