c# - 如何在我的 Visual Studio 解决方案中找到所有命名空间?

标签 c# .net visual-studio visual-studio-2012 namespaces

我问这个问题是因为我的解决方案中出现编译错误: “GiftCard”是一个“命名空间”,但像“类型”一样使用

我尝试添加一个 using 指令,例如: 使用 GiftCard.Data.Entity;

这是找到 GiftCard 的正确命名空间,但错误并没有消失。当我在代码中添加完全限定名称时,即 GiftCard.Data.Entity.GiftCard

...然后错误消失,代码编译。

但我想知道为什么 using 指令不起作用。我不想每次需要使用该类型时都用完全限定名称来混淆我的代码。不知何故,错误消息说我在某处将 GiftCard 定义为命名空间。那么我如何才能找到我的解决方案中的所有命名空间,以便我知道它的定义位置,因为我需要删除或重命名 GiftCard 命名空间。

最佳答案

您的问题与您的问题不太相关。

问题

The Framework Design GuidelinesDo not use same name for a namespace and a type in that namespace

For example, do not use Debug as a namespace name and then also provide a class named Debug in the same namespace. Several compilers require such types to be fully qualified.

即:

namespace Debug
{
    public class Debug{ … }
}

namespace MyContainers.List
{
    public class List { … }
}

为什么会这样? Do not name a class the same as its namespace

问题的答案

查看 -> 对象浏览器(快捷键:Ctrl+Alt+J)

关于c# - 如何在我的 Visual Studio 解决方案中找到所有命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31644527/

相关文章:

c# - 当我通过 jquery 发布时服务器验证不起作用

c# - 将 JSON 日期信息解析为 C# DateTime

c# - 创建线程 - Task.Factory.StartNew 与 new Thread()

c# - 将 .net 应用程序从 32 位转换为 64 位

c - Stream != nullptr Visual Studio,简单地打印 txt 文件中的值 (C)

visual-studio - 按名称附加到 Visual Studio 进程

c# - 您能否将装饰器的位置附加到装饰元素左上角以外的任何位置?

c# - 绑定(bind) WPF 组合框并将其值显示到 TextBox

c# - 重命名文件自己打开

mixed-mode - 混合模式库和 CRT 依赖项 - 帮助