开发者

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 e开发者_StackOverflow中文版xtra bonus)


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


escape the xml entities.

Change <T> into &lt;T&gt;


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


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 


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜