vb.net 如何为函数和函数参数添加描述?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5717359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add description to functions and function parameters?
提问by Phonon
I'm writing a VB.NET function with a ton of overloads. I've seen that most .NET functions have parameter descriptions in IntelliSense. For example, when typing in String.Compare(
, IntelliSense says Compares two specified System.String objects and returns...
you get the idea. This description changes and you click through different overloaded versions of the same functions. When you start typing in something for a parameter, it describes the parameter you're currently inputting as well. Example: strA: The first string to compare.
.
我正在编写一个带有大量重载的 VB.NET 函数。我已经看到大多数 .NET 函数在 IntelliSense 中都有参数描述。例如,在输入 时String.Compare(
,IntelliSense 会说Compares two specified System.String objects and returns...
您明白了。此描述会发生变化,您可以单击相同功能的不同重载版本。当您开始为参数输入某些内容时,它也描述了您当前输入的参数。例子:strA: The first string to compare.
。
How can I give such descriptions to my functions?
我怎样才能对我的功能进行这样的描述?
回答by Jeff Stock
All you have to do is key three apostrophes on the line before your function. .NET will add the rest of the code for you. Insert the text you want displayed in the intellisense in the tag.
您所要做的就是在您的函数之前的行上键入三个撇号。.NET 将为您添加其余的代码。在标签中插入想要在智能感知中显示的文本。
''' <summary>
''' Returns the name of the code.
''' </summary>
Function GetName() As String
Return "Something"
End Function
回答by Hyman
For the parameters...
对于参数...
''' <summary>
''' Procedure description
''' </summary>
''' <param name="someVariable">someVariable description.</param>
''' <param name="someVariable">someVariable description.</param>
''' <remarks></remarks>
回答by Smudge202
Right click a method/member name and choose 'Insert Comment' from the context menu.
右键单击方法/成员名称,然后从上下文菜单中选择“插入注释”。
The contents of the XML for the member/method will be displayed in some versions of Visual Studio, inside intellisense tip windows.
成员/方法的 XML 内容将显示在某些版本的 Visual Studio 中,在智能感知提示窗口内。
''' <summary>
''' Summary for the method goes here
''' </summary>
''' <param name="value">Param comments go here</param>
''' <remarks></remarks>
Private Sub SomeMethod(ByVal value As Decimal)
回答by rigamonk
Use xml comments. There are some predefined tags that load into intellisense after you compile. and the wonderful thing is, if you place your cursor on the line above your function, then press ''' (triple-single quote, if that makes sense) and enter, it will prefill a bunch of stuff for you. Heres an article:
使用 xml 注释。编译后有一些预定义的标签会加载到智能感知中。奇妙的是,如果您将光标放在函数上方的行上,然后按 '''(三重单引号,如果有意义)并输入,它会为您预填充一堆东西。这里有一篇文章:
回答by Guffa
Place the cursor on the line before the method and type three apostrophes ('''
). You will get a template for writing XML documentation for the method and it's parameters.
将光标放在方法之前的行上并键入三个撇号 ( '''
)。您将获得一个模板,用于为方法及其参数编写 XML 文档。