如何在多个项目中使用我的课程?

发布于 11-14 20:27 字数 73 浏览 3 评论 0原文

如何在其中创建命名空间和类,然后保存它,并在其他项目中重用该命名空间?我是否必须在 Visual Studio 中单击“创建类库”?

How can I create a namespace and classes in it, then save it, and reuse the namespace in other projects? Do I have to click on Create Class Library in Visual Studio?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乞讨2024-11-21 20:27:13

中找到了答案

我在 理解和使用 .NET 中的程序集和命名空间 strong>这是您需要执行的操作:

  1. 创建类库

  2. 构建它以生成 .dll 文件

  3. 并添加对该dll文件的引用
    在任何项目中使用它

I found the answer in Understanding and Using Assemblies and Namespaces in .NET

Here's what you need to do:

  1. Create a Class Library

  2. Build it to generate a .dll file

  3. And add a reference to the dll file
    in any project to use it
情深已缘浅2024-11-21 20:27:13

要创建类型并在多个项目中使用它们,您需要将它们放置在单独的程序集中。该程序集可以从类库或任何其他项目类型生成。程序集文件的类型可以是动态库可执行文件

您可以将这些类型放置在特定的命名空间中。此外,您还可以将它们放置在多个命名空间中。

要从外部项目使用这些类型,您必须执行以下操作:

  1. 添加对提到的程序集的引用。

  2. 导入代码文件中包含这些类的命名空间。或者,使用它们的完全限定名称。


请参阅在 VB.NET 中实现类库

Sort of .. To create types and use them in several projects you need to place them in a seperate assembly. This assembly could be generated from a class library, or any other project type. The type of the assembly file could be either a dynamic library or an executable.

You can place those types in a specific namespace. Also, you can place them in several namespaces.

To use these types from an external project you have to do the following:

  1. Add a reference to the mentioned assembly.

  2. Either importing the namespaces that contains those classes in your code file. Or, using their fully qualified names.


Refer to Implementing a Class Library in VB.NET

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文