我们如何创建类库并在c#中使用它们 [英] how we create class libraries and using them in c#

查看:79
本文介绍了我们如何创建类库并在c#中使用它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何创建类库并在c#中使用它们

how we create class libraries and using them in c#

推荐答案

简单:

在Visual Studio中打开您的解决方案,然后右键单击解决方案资源管理器窗格中的解决方案名称。

从显示的菜单中选择添加...然后选择新建项目...

这将显示新建项目对话框 - 在左侧选择Visual C#,然后在中间选择类库。

给它一个合适的名字然后按确定。这将使用默认的Class1类将类库项目添加到您的解决方案。

构建您的解决方案。



现在,去到解决方案资源管理器中要使用库的项目。

右键单击项目的引用分支,然后选择添加引用...

等待对话 - 可能需要一些时间 - 然后选择左侧的项目。

选择新库,然后按添加,然后按关闭。 />
转到要使用库的文件,并使用语句添加相应的



它现在可用了!
Easy:
Open your solution in Visual studio, and right click the solution name in the Solution Explorer pane.
From the menu that appears, select "Add..." Then "New Project..."
This will bring up the "New project" dialog - select "Visual C#" on the left hand side, and then "Class Library" in the middle.
Give it an appropriate Name and press "OK". This will add the class library project to your solution, with a default "Class1" class.
Build your solution.

Now, go to the project where you want to use the library in the Solution Explorer.
Right click the "References" branch for the project, and select "Add Reference..."
Wait for the dialog - it can take a little time - then select "Projects" on the left hand side.
Select the new library, and press "Add", then "Close".
Go to the file where you want to use the library, and add the appropriate using statement.

It's now available!


演练:使用类库创建Web应用程序项目 [ ^ ]


这篇关于我们如何创建类库并在c#中使用它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆