46

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..

How can I give such descriptions to my functions?

5 Answers 5

83

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
0
40

For the parameters...

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

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

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

3

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.