简体   繁体   中英

Enum Intellisense Display Attribute?

I want to do this:

enum Foo
{
    [Display="Item One"]
    ItemOne,
}

So that Intellisense will display it like in the attribute instead of the actual name.

I know it's possible, I've seen it before.

Well you could provide XML documentation:

enum Foo
{
    /// <summary>Item One</summary>
    ItemOne
}

I'm not sure whether that's quite what you were thinking of, but here's an example of what it looks like in VS 2010:

带有枚举的IntelliSense

Note that I'm assuming you mean from the code editor... if you mean within a property editor, that could be something entirely different, eg DisplayNameAttribute (although that's meant for properties, events or methods).

If you know an example of what you want within the framework, we may be able to help more.

As a note... if you are building a .dll that is to be referenced by another application, just writing a summary will not allow the text to show up in intellisense for the referencing application. To accomplish this, you must deploy the XML documentation file as well, which requires a re-compiled version of the same .dll.

To do this (in VS2008 anyways), go into the Properties of your project, click the Build tab, click the checkbox at the bottom next to 'XML documentation file:', rebuild the application, and now you have the files needed to make it work.

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