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

Open a .cs file in an editor.

Switch to Code view.

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:

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.