枚举智能感知显示属性?
我想这样做:
enum Foo
{
[Display="Item One"]
ItemOne,
}
这样智能感知就会像在属性中一样显示它而不是实际名称。
我知道这是可能的,我以前见过。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,您可以提供 XML 文档:
我不确定这是否正是您所想的,但这里有一个 VS 2010 中的示例:
请注意,我假设您的意思是从代码编辑器中...如果您的意思是在属性编辑器中,那可能是完全不同的东西,例如
DisplayNameAttribute
(尽管这适用于属性、事件或方法) 。如果您知道框架内您想要的内容的示例,我们也许能够提供更多帮助。
Well you could provide XML documentation:
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:
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.
请注意...如果您正在构建要由另一个应用程序引用的 .dll,则仅编写摘要将不允许文本显示在引用应用程序的智能感知中。为此,您还必须部署 XML 文档文件,这需要同一 .dll 的重新编译版本。
要执行此操作(无论如何在 VS2008 中),请进入项目的“属性”,单击“生成”选项卡,单击底部“XML 文档文件:”旁边的复选框,重建应用程序,现在您拥有了制作所需的文件它起作用了。
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.