242

这应该更容易...

我想在我的代码中的 XML 文档中添加一个“编码”换行符

/// <summary>
/// Get a human-readable variant of the SQL WHERE statement of the search element. &lt;br/&gt;
/// Rather than return SQL, this method returns a string with icon-tokens, which 
/// could be used to represent the search in a condensed pictogram format.
/// </summary>

如您所见,我找到了一些演示添加 < 和 > 括号的答案。有趣的是,好的 'ol < br/> 换行符不会在 Intellisense 弹出窗口中创建换行符。

我觉得这很烦人...

有什么建议么?

4

5 回答 5

380

您可以使用<para />标签来产生分节符,或者您可以将文本包装在<para></para>标签中作为对文本进行分组并在其后添加空行的一种方式,但没有等效<br />或类似的东西。(根据这个旧的 MS 论坛帖子是设计使然。)您可以从 MS 获取此文档文章中的可用标签列表。记录您的代码

示例(基于原始 OP 示例):

/// <summary>
/// <para>Get a human-readable variant of the SQL WHERE statement of the search element.</para>
/// Rather than return SQL, this method returns a string with icon-tokens, which 
/// could be used to represent the search in a condensed pictogram format.
/// </summary>
于 2011-09-02T04:04:48.900 回答
146

从 Visual Studio 2019 开始,<br/>用于注释中的换行符。

例子:

/// <summary>
/// This is a comment.<br/>
/// This is another comment <br/>
/// This is a long comment so i want it to continue <br/> on another line.
/// </summary>

在此处输入图像描述

请注意,当我们使用<br/>而不是<para>.

于 2019-08-31T01:17:46.977 回答
89

这是我的用法,就像<br/>,它正在工作:)

/// <summary>
/// Value: 0/1/2
/// <para/>0 foo,
/// <para/>1 bar,
/// <para/>2 other
/// </summary>
于 2014-09-02T02:56:42.893 回答
26

添加一个<para>带有特殊字符的标签,即 255 字符或不可见字符

/// <summary>
/// Some text
/// <para>   </para>
/// More text
/// </summary>
/// <param name="str">Some string</param>
public void SomeMethod(string str) { }

它将像这样工作:

在此处输入图像描述

于 2013-04-10T12:03:18.910 回答
3

<br></br>并且<br />似乎不起作用,有时它并不是真正将<para>句子分开,而是希望有一个空白行来分离关注点。我在这里提到这一点是因为这个问题似乎是许多这种性质的封闭问题的父母。

我发现唯一有用的是

<para>&#160;</para>

例如

/// <summary>
///     <para>
///         "This sentence shows up when the type is hovered"
///     </para>
///     <para>&#160;</para>
///     <para>int PrimaryKey</para>
///     <para>&#160;</para>
///     <para>virtual Relation Relation</para>
/// </summary>

结果是

"This sentence shows up when the type is hovered"

int PrimaryKey

virtual Relation Relation
于 2014-08-04T22:07:36.730 回答