Visual Studio 2010 在智能感知中两次列出相同的枚举

发布于 2024-12-17 16:25:32 字数 606 浏览 3 评论 0原文

我使用的是 Visual Studio 2010 专业版。在这个问题中,CardSet 是在“Entities”命名空间中声明的枚举。

当我开始输入“Car”时,如果我点击 Tab,自动完成功能始终会变为 Entities.CardSet 而不仅仅是 CardSet。这种情况发生在与枚举相同的命名空间中声明的类方法中。

该枚举在 Intellisense 中列出了两次:

枚举的源文件和正在编辑的类的源文件位于不同的文件夹中。 CardSet 仅声明一次。第二个命名空间中没有单独的 CardSet 枚举。

奇怪的是“实现抽象类”生成的代码不使用命名空间 - 它正确地使用了较短的 CardSet

如何让 Visual Studio 从 Intellisense 中获取 Entities.CardSet 以便我只需输入
“汽车+标签”?我尝试过重新启动 Visual Studio,但没有效果。

I'm using Visual Studio 2010 Professional. In this question, CardSet is an enum declared in the "Entities" namespace.

When I start typing in "Car", if I hit tab the auto-completion always becomes Entities.CardSet instead of just CardSet. This is occurring in a class method declared in the same namespace as the enum.

The enum is listed twice in Intellisense:

The source files for the enum and for the class being edited are in different folders. CardSet is declared only once. There is not a separate CardSet enumeration in a second namespace.

What is odd is code generated by "Implement abstract class" doesn't use the namespace - it correctly uses the shorter CardSet.

How can I get Visual Studio to get Entities.CardSet out of Intellisense so I can just type in
"Car +Tab"? I have tried restarting Visual Studio to no effect.

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

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

发布评论

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

评论(2

绮筵 2024-12-24 16:25:32

我只是捂脸。这是因为类上有一个名为 CardSet 的属性。我需要解决这个问题。我刚刚注意到 Intellisense 中的图标不同:一个用于属性,另一个用于枚举。

I just facepalmed. It's because there's a property on the class also called CardSet. I need to fix that. I just noticed the icons in Intellisense are different: one is for a property while the other is for an enum.

贪了杯 2024-12-24 16:25:32

它没有列出枚举两次。它列出了两个条目,因为您可能需要引用两个不同的内容:类型中的 CardSet 属性/字段,或枚举类型本身 (Entities.CardSet)然后引用枚举的特定成员。请注意图标的不同之处。

这种行为对我来说似乎并非不合理 - 它真的对您的工作效率影响那么吗?如果您确实不想键入全部七个字符,只需从下拉列表中选择正确的值即可。

It's not listing the enum twice. It's listing two entries because there are two different things you might want to refer to: the CardSet property/field within your type, or the enum type itself (Entities.CardSet) to then refer to a specific member of the enum. Note how the icons are different.

The behaviour doesn't seem unreasonable to me - is it really affecting your productivity that much? If you really don't want to type all seven characters, just select the right value from the dropdown.

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