【问题标题】:How to add items enclosed by < > to documentation comments如何将 < > 括起来的项目添加到文档注释中
【发布时间】:2011-01-22 23:12:09
【问题描述】:
我正在尝试编写文档 cmets,但是我遇到了问题。
/// <summary>
/// Inserts an element into the System.Collections.Generic.List<T> at the specified
/// index.
/// </summary>
当我到达<T> 时,Visual Studio 认为我正在尝试添加另一个标签。添加这样的 cmets 的正确方法是什么(如果我可以让它们在生成的帮助文本中可点击,那将是额外的奖励)
【问题讨论】:
标签:
c#
.net
visual-studio-2008
documentation
comments
【解决方案1】:
由于注释是 xml,您可以为 xml 使用适当的转义序列:
/// Inserts an element into the System.Collections.Generic.List<T> at the specified
【解决方案3】:
C# 文档 cmets 是 XML,因此请将您的 &lt; 和 &gt; 更改为 &lt; 和 &gt;。
不过,最好使用<see> 标签插入超链接。在<see> 标记中,将<T> 更改为{T}:
/// <summary>
/// Inserts an element into the <see cref="List{T}"/> at the specified
/// index.
/// </summary>
(请注意,cref 属性由编译器进行语法检查,与普通文本不同。)
【解决方案5】:
您需要使用正确的字符代码:&lt;和&gt;。
您可能希望将整个 System.Collections.Generic.List 包裹在 <see cref="..."/> 标记中。
我实际上不得不使用上面提到的标签来正确写这个答案:)