Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 754
Phonon Avatar asked Apr 19 '11 13:04

Phonon


People also ask

How do you write a description of a function?

In a function description, the name of the function being described appears first. It is followed on the same line by a list of argument names. These names are also used in the body of the description, to stand for the values of the arguments.

How do you add a comment to a function?

To comment on a parameter, start the line with @param , followed by the parameter's name, and then a short description of what the function will do.

How do you declare a function parameter?

In a function declaration, or prototype, the type of each parameter must be specified. In the function definition, the type of each parameter must also be specified. In the function definition, if the type of a parameter is not specified, it is assumed to be int .

Can you put a function in a parameter?

A function can take parameters which are just values you supply to the function so that the function can do something utilising those values. These parameters are just like variables except that the values of these variables are defined when we call the function and are not assigned values within the function itself.


3 Answers

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
like image 110
Jeff Stock Avatar answered Oct 13 '22 23:10

Jeff Stock


For the parameters...

''' <summary>
''' Procedure description
''' </summary>
''' <param name="someVariable">someVariable description.</param>
''' <param name="someVariable">someVariable description.</param>
''' <remarks></remarks>
like image 21
Jack Avatar answered Oct 13 '22 23:10

Jack


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)
like image 22
Smudge202 Avatar answered Oct 13 '22 23:10

Smudge202