Share via


Supplying Code Comments

Code comments refer to comments placed in source code files that are then available to users of the Visual Studio .NET development environment via the IntelliSense feature.

[Visual Basic]

Visual Basic does not support code comments.

[C#]

You can use the XML Documentation feature to comment code. These comments will be displayed through the List Members option.

[C++]

By default, any comments in the source code that use the // or /* delimiters are displayed next to their associated member in the Members list. As you scroll through the list, IntelliSense displays up to 12 lines of the comment in a pop-up window next to the highlighted member.

When more than one comment exists for a function, IntelliSense determines which comment to display in the Members list by where it appears in the code:

  1. IntelliSense will first display end-of-line comments in the declaration. For example:

    void MyFunction();   //EOL declaration comments
    
  2. If IntelliSense does not find the previous type of comment, it will display comments that appear directly above the declaration with no blank lines in between. For example:

    //Before declaration comments
       void MyFunction();
    
  3. If the previous two types of comments are not found in the code, IntelliSense will display end-of-line comments in the definition. For example:

    int CMyAppDoc::MyVariable=2; // EOL definition comments
    
  4. Finally, if none of the previous types of comments appear in the code, IntelliSense will display comments that appear directly above the definition with no blank lines in between. For example:

    //Before definition comments
    CMyAppDoc::MyFunction() 
    {
       return; 
    }
    

See Also

Using IntelliSense | List Members