This documentation is archived and is not being maintained.

Adding Comments in C# Code

Visual Studio .NET 2003

You can easily add comments within the structure of your C# code and view them by using code comment Web reports. Comments and XML tags displayed in a code comment Web report are prefaced with the comment syntax ///. Typically, comments are entered before user-defined types such as a class, struct, or interface; members such as a field, event, property, or method; or a namespace declaration.

To add comments in C# code

  1. Open a .cs file in an editor.
  2. Switch to Code view.
  3. Enter /// followed by any XML tags or text strings. If you enter /// on the line before the definition, the editor creates a template of a documentation comment and fills in the parameters and other information.

    For example, in the file class1.cs before public Class1() you could enter the following:

    ///summary description
    ///This is a test.

In the code structure for the Class1, the information listed within the <summary></summary> tags appears in the Description column. The information listed within <remarks></remarks> tags appears on the detailed page for class1 in the Remarks section. For a list of supported XML tags, see Creating Code Reports.

See Also

Viewing Code Structure with Comments | Build Comment Web Pages Dialog Box | Creating Code Reports | Tags for Documentation Comments