1、C#代码打成DLL
创建或者打开C#项目,在资源管理器界面选中当前项目右击,如图
打开如下, 选中类库,Ctrl+S,保存下,
这里是dll保存的位置,如图
再右击项目如图,点击重新生成,就可以了,如图
2、在项目里引用dll
在这里就可以看到引用成功了
接下来,开始试试吧,注意引入 using TestDll; 我这里在dll里写了个简单加法
using System.Text;
using System.Threading.Tasks;
using TestDll;
namespace TestUseDll
{
class Program
{
static void Main(string[] args)
{
int num = TestDll.TestMath.Add(1, 1);
TestDll.TestPrint.PrintHelloWorld("TestDll.TestMath.Add--------------->" +num.ToString());
Console.Read();
}
}
}
运行如图