6

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)

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431

5 Answers5

10

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.)

Tim Robinson
  • 53,480
  • 10
  • 121
  • 138
2

escape the xml entities.

Change <T> into &lt;T&gt;
Marvin Smit
  • 4,088
  • 1
  • 22
  • 21
2

I believe this would be of help for you: C# XML documentation comments FAQ.

Andras Vass
  • 11,478
  • 1
  • 37
  • 49
0

Since the comment is xml you can use appropriate escape sequences for xml:

/// Inserts an element into the System.Collections.Generic.List&lt;T&gt; at the specified 
Aurril
  • 2,469
  • 2
  • 24
  • 38
0

You need to use the proper char codes: &lt; and &gt;.

You would want to surreound the whole System.Collections.Generic.List<T> in a <see cref="..."/> tag.

I actually had to use the above mentioned tags to correctly write this answer :)

slugster
  • 49,403
  • 14
  • 95
  • 145