开发者

Enum Intellisense Display Attribute?

I want to do this:

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

So that Intellisense will display it like in the attri开发者_运维技巧bute 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:

Enum Intellisense Display Attribute?

Note that I'm assuming you mean from the code editor... if you mean within a property editor, that could be something entirely different, e.g. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜