C#中创建和使用动态链接库
2017-09-22 16:29
288 查看
动态链接库英文为DLL,是DynamicLinkLibrary的缩写形式,DLL是一个包含可由多个程序同时使用的代码和数据的库,它有助于共享数据和资源。
(一)创建动态链接库
1)新建一个类库
2)编写该类库
例如:
3)生成动态链接库
(二)使用动态链接库
1)添加引用
右击项目-添加引用-浏览找到本地的dll文件
2)using该dll文件里面代码的名称空间
例如:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
//using要引用的dll文件的命名空间
usingDllTest;
namespaceDllExample
{
classProgram
{
staticvoidMain(string[]args)
{
DllTest.MyClassmyTest=newDllTest.MyClass();
myTest.ShowMessage();
}
}
}
(一)创建动态链接库
1)新建一个类库
2)编写该类库
例如:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
namespaceDllTest
{
publicclassMyClass
{
publicvoidShowMessage()
{
Console.WriteLine("你已成功调用了动态链接!");
Console.ReadLine();
}
}
}
3)生成动态链接库
(二)使用动态链接库
1)添加引用
右击项目-添加引用-浏览找到本地的dll文件
2)using该dll文件里面代码的名称空间
例如:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
//using要引用的dll文件的命名空间
usingDllTest;
namespaceDllExample
{
classProgram
{
staticvoidMain(string[]args)
{
DllTest.MyClassmyTest=newDllTest.MyClass();
myTest.ShowMessage();
}
}
}
相关文章推荐
- c#创建Dll动态链接库、C#使用动态链接库
- 使用C#进行动态链接库的创建和使用
- c#创建Dll动态链接库、C#使用动态链接库
- C#创建Dll动态链接库、C#使用动态链接库
- 创建和使用动态链接库 (C++)C#调用
- c#创建Dll动态链接库、C#使用动态链接库
- c#创建Dll动态链接库、C#使用动态链接库
- c#创建Dll动态链接库、C#使用动态链接库
- C#中创建和使用资源动态链接库
- vs2010 创建和C#使用动态链接库(dll)
- C#中创建和使用动态链接库
- c#创建Dll动态链接库、C#使用动态链接库
- Linux静态/动态链接库的创建和使用
- 使用C#创建webservice及三种调用方式
- LINUX系统中动态链接库的创建与使用
- Linux静态/动态链接库的创建和使用
- 企业信息化系统基础——AD:使用C#批量创建帐号
- Linux静态/动态链接库的创建和使用
- 如何创建和使用 C# DLL(受托管)
- Linux静态/动态链接库的创建和使用