开发者

How to add description to functions and function parameters?

I'm writing a VB.NET function with a ton of overloads. I've seen that m开发者_StackOverflow社区ost .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..

How can I give such descriptions to my functions?


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.

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


For the parameters...

''' <summary>
''' Procedure description
''' </summary>
''' <param name="someVariable">someVariable description.</param>
''' <param name="someVariable">someVariable description.</param>
''' <remarks></remarks>


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.

    ''' <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)


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:

Documenting Your Code with XML Comments


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜