如何为自定义创建的类获取智能感知?
当你输入“这个”时。 ,您通常会获得当前班级的所有例程、事件等。当您只是站在长列表中的一个例程而不选择其中一个时,您通常会在它旁边看到一个描述。
我怎样才能做到这一点? 假设我有一个名为 CAR 的类,它有两个例程:speed_up() 和brake()。 如何让使用我的类的人在输入时看到这两个函数的描述:
CAR mycar = new CAR();
mycar.
When you type "this." , you usually get all the routines, events, and more... of the current class you are in. And when you simply stand over one of the routines in the long list without choosing one, you usually get a description next to it.
How can I do that ?
Let assume I have a class called CAR with two routines: speed_up(), and brake().
How can I make the person using my class to see a description of the two functions when he types:
CAR mycar = new CAR();
mycar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
为您的班级及其成员提供 XML 注释,这些注释将显示在智能感知。在 Visual Studio 中执行此操作的最简单方法是在要添加注释的内容上方键入
///
。例如:
上述内容可在此处找到。
另请参阅:如何让 XML 注释出现在不同的项目 (dll) 中?
Give your classes and their members, XML comments, which will appear in intellisense. The easiest way of doing this in visual studio is by typing
///
above what you want to add comments to.For example:
The above was found here.
See also: How do you get XML comments to appear in a different project (dll)?
您应该对每个类型构造(即类、方法、属性...)使用 Visual Studio 中可用的 XML 文档格式。
要访问它,请在声明之前的行中键入 ///。
例如:
你会得到类似的信息:
如果你输入 ///<您甚至可以获得可用 XML 元素的列表,例如备注或示例
有关详细信息,请参阅 http://msdn.microsoft.com/en-us/杂志/cc302121.aspx
You should use the XML documentation format available in Visual studio for every type constructs (ie class, methods, properties...)
To access it, type /// on the line before your declaration.
For instance:
you will get something like:
if you type ///< you will even get the list of available XML elements, like remarks or exemple
For more informations, see http://msdn.microsoft.com/en-us/magazine/cc302121.aspx
您可以这样发表评论:
You can put comments like this:
你必须这样注释:
你可以描述函数
的用法以及参数的含义
.如果函数有返回值,可以用标签
来描述它。支持一些 mor 标签,当您在三个\
之后写下评论时,Visual Studio 会列出这些标签。You have to put a comment on it like this:
You can describe the usage of the function
<summary>
and the meaning of the paramaters<param name="">
. If the function has a return value, you can describe it with the tag<returns>
. There are some mor tags supported, the will be listed by visual studio, when you write your comment after three\
.尝试通过键入
///
向您的方法添加摘要,并像下面一样填写,您可以对每个方法和属性执行此操作,以便它在 Intellisense 中有意义地显示意图。
Try adding a summary to your methods by keying in
///
and fill up like belowyou can do this for each of the methods and properties, so that it meaningfully displays the intent in Intellisense.
您需要为方法添加文档注释。您可以通过键入“///”或使用 Visual Studio 插件手动执行此操作。如果您遵循良好的命名约定 GhostDoc 添加将对您有很大帮助。
You need to add document comments for the methods. you can do this manually by typing '///' or using visual studio addin. If you follow good naming conventions GhostDoc adding will help you lot on this.
在类或方法之上,而不是“//”注释。如果您使用“///”三斜杠(也称为 XML 注释),它会执行一个快捷方式,以允许您填写有关您正在注释的类或方法的信息。
然后,这会出现在您的代码中,
当您通过智能感知访问类或方法时,描述就会出现。
Above a class or a method, rather than a "//" comment. if you do a "///" triple slash ( otherwise known as an XML comment ), it performs a short cut to allow you to fill information out about the class or method you are commenting on.
This then appears in your code as such
When you then access the class or method through intellisense thats when the description will appear.