在C#中如何编写dll文件?
要创建私有程序集,我们将按以下步骤操作:
- 首先打开Visual Studio 2010.
- 然后单击"文件"菜单然后"新建"选项。
- 然后单击"项目"菜单并选择c# "类库"模板。
- 然后填写DLL名称并记住位置并单击"确定"。
- 然后写下以下DLL代码。
这里我们给我们的DLL命名为“mydll”。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace mydll
{
public class operation
{
public int add(int x, int y)
{
int sum = x + y;
return sum;
}
}
}
然后按F6或者单击"构建"菜单上的"构建解决方案"以编译DLL。
现在我们的DLL已经构建好,可以通过添加它的引用在其他应用程序中使用。
日期:2020-04-11 23:03:40 来源:oir作者:oir
