简体   繁体   中英

Visual Studio 2010 listing the same enum twice in intellisense

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM