在本地PC上的完全限定命名空间

huangapple go评论68阅读模式
英文:

Fully Qualified Namespace on Local PC

问题

大家早上好。我在VS2022和C#方面是个完全的新手。我在命名空间A下创建了一个类B,在本地PC上的C:\Users\un\source\repos\A存储的项目中。我想在不同解决方案中的一个新类中引用类B。我该如何在新类中完全限定命名空间A?

我尝试过:

使用 B;

但出现了错误:

错误 CS0246 类型或命名空间名称 'B' 无法找到(您是否缺少 using 指令或程序集引用?

英文:

Morning all. I'm a total noob at VS2022 and C#. I have created a class B in namespace A in a project that is on my local PC stored in C:\Users\un\source\repos\A. I want to reference class B in a new class in a different solution. How do I fully qualify the namespace A in a new class?

I've done a lot of googling but couldn't find an answer. Maybe I am using the wrong terminology.

EDIT: @user09938 The new class is in a different solution than namespace A.

Thank you!

I tried:

using B;

and got the error:

Error CS0246 The type or namespace name 'B' could not be found (are you missing a using directive or an assembly reference?

答案1

得分: 0

如果类B位于与类A不同的项目中,包含类A的项目将需要引用包含类B的项目(解决方案资源管理器,依赖项,右键单击,添加项目引用...)。

英文:

If class B is in a different project from class A, the project that contains class A will need to reference the project that contains class B (Solution Explorer, Dependencies, right-click, Add Project Reference...).

huangapple
  • 本文由 发表于 2023年3月20日 23:45:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75792413.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定