【问题标题】: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>

当我到达&lt;T&gt; 时,Visual Studio 认为我正在尝试添加另一个标签。添加这样的 cmets 的正确方法是什么(如果我可以让它们在生成的帮助文本中可点击,那将是额外的奖励)

【问题讨论】:

    标签: c# .net visual-studio-2008 documentation comments


    【解决方案1】:

    由于注释是 xml,您可以为 xml 使用适当的转义序列:

    /// Inserts an element into the System.Collections.Generic.List&lt;T&gt; at the specified 
    

    【讨论】:

      【解决方案2】:

      转义 xml 实体。

      改成 ;

      【讨论】:

        【解决方案3】:

        C# 文档 cmets 是 XML,因此请将您的 &amp;lt;&amp;gt; 更改为 &amp;lt;&amp;gt;

        不过,最好使用&lt;see&gt; 标签插入超链接。在&lt;see&gt; 标记中,将&lt;T&gt; 更改为{T}

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

        (请注意,cref 属性由编译器进行语法检查,与普通文本不同。)

        【讨论】:

          【解决方案4】:

          我相信这会对您有所帮助:C# XML documentation comments FAQ

          【讨论】:

          • 谢谢,我一直喜欢写得很好的常见问题解答
          • 如果它有帮助我很高兴 - 它确实有时对我有用。
          【解决方案5】:

          您需要使用正确的字符代码:&amp;lt;和&amp;gt;。

          您可能希望将整个 System.Collections.Generic.List 包裹在 &lt;see cref="..."/&gt; 标记中。

          我实际上不得不使用上面提到的标签来正确写这个答案:)

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2015-08-23
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多