如何在函数和函数参数中添加描述?

Pho*_*non 40 vb.net user-defined-functions

我正在编写一个带有大量重载的VB.NET函数.我已经看到大多数.NET函数在IntelliSense中都有参数描述.例如,在输入时String.Compare(,IntelliSense表示Compares two specified System.String objects and returns...您明白了.此说明更改,您单击相同功能的不同重载版本.当您开始为参数键入内容时,它还会描述您当前正在输入的参数.示例:strA: The first string to compare..

我怎样才能对我的功能进行这样的描述?

Jef*_*ock 72

所有你需要做的就是在你的功能之前在线上键入三个撇号..NET将为您添加其余代码.将要显示的文本插入标记中的intellisense中.

''' <summary>
''' Returns the name of the code.
''' </summary>
Function GetName() As String
    Return "Something"
End Function
Run Code Online (Sandbox Code Playgroud)


Jac*_*ack 37

对于参数......

''' <summary>
''' Procedure description
''' </summary>
''' <param name="someVariable">someVariable description.</param>
''' <param name="someVariable">someVariable description.</param>
''' <remarks></remarks>
Run Code Online (Sandbox Code Playgroud)


Smu*_*202 22

右键单击方法/成员名称,然后从上下文菜单中选择"插入注释".

成员/方法的XML内容将显示在一些版本的Visual Studio中,在intellisense tip窗口中.

    ''' <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)
Run Code Online (Sandbox Code Playgroud)


rig*_*onk 7

使用xml注释.编译后,有一些预定义的标签加载到intellisense中.奇妙之处在于,如果你将光标放在功能上方的线上,然后按'''(三重单引号,如果有意义的话)并输入,它会预先填充一堆东西给你.下面是一篇文章:

使用XML注释记录您的代码