您的位置:首页 > 编程语言 > C#

C#中dll的創建和使用

2016-05-09 00:15 447 查看
一、DLL的創建

1、新建項目類庫

2、編寫需要使用的函數

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace howtocreatedll

{

public class Class1

{

public void a()

{

MessageBox.Show("biaoti", "neirong");

}

}

}

3、生成解決方案

4、在bin的debug中就可以找到dll文件

二、dll的調用

1、首先將dll文件放到新的專案中

2、點擊“引用”,點擊“添加引用”,將dll找到

3、在申明中添加using xxdll ;

4、對對要使用的類進行實例化

using howtocreatedll;

namespace usedll

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

howtocreatedll.Class1 class12 = new howtocreatedll.Class1();

class12.a();

}

}

}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: