Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add items enclosed by < > to documentation comments

I am trying to write documentation comments however I have a problem.

/// <summary>
/// Inserts an element into the System.Collections.Generic.List<T> at the specified
/// index.
/// </summary>

When I reach the <T> Visual studio thinks I am trying to add another tag. what is the correct way to add comments like that (and if I could make them click able in the generated help text that would be a extra bonus)

like image 267
Scott Chamberlain Avatar asked Mar 02 '10 22:03

Scott Chamberlain


People also ask

How do you write a summary comment in C#?

The first rule for commenting is it should have /// three slash for comments as C# supports C++ style commenting so commenting can be done by // -- two slashes -- but for Documentation /// is necessary. We will go through each one by one. You can add a paragraph to the description by using <para> tag.

How do I comment out code in C#?

Single-line comments start with two forward slashes ( // ). Any text between // and the end of the line is ignored by C# (will not be executed).

What is triple slash in C#?

XML documentation comment is a special feature in C#. It starts with a triple slash /// and is used to categorically describe a piece of code.. This is done using XML tags within a comment. These comments are then, used to create a separate XML documentation file.


1 Answers

C# documentation comments are XML, so change your < and > to &lt; and &gt;.

What you're better off doing, though is, is using the <see> tag to insert a hyperlink. In a <see> tag, change <T> to {T}:

/// <summary>
/// Inserts an element into the <see cref="List{T}"/> at the specified
/// index.
/// </summary>

(Note that the cref attribute is syntax-checked by the compiler, unlike ordinary text.)

like image 79
Tim Robinson Avatar answered Oct 22 '22 11:10

Tim Robinson