如何在 C# .NET 文档中添加换行符

发布于 2024-12-02 08:36:53 字数 510 浏览 1 评论 0原文

这应该更容易...

我想在我的代码中的 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 弹出窗口中创建换行符。

我觉得这很烦人...

有什么建议吗?

This should be waaaay easier...

I want to add a "coded" line break to the XML documentation in my code

/// <summary>
/// Get a human-readable variant of the SQL WHERE statement of the search element. <br/>
/// 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>

As you can see, I found some answers that demonstrated adding < and > brackets.
Interestingly, the good 'ol < br/ > line break does not create a line break in the Intellisense popup.

I find this annoying...

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

半世蒼涼 2024-12-09 08:36:53

您可以使用 标记来生成段落分隔符,也可以将文本包裹在 标记中将文本分组并在其后添加空行,但没有与
或类似的内容等效的内容。 (根据 这个旧的 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>

You can use a <para /> tag to produce a paragraph break or you can wrap text in <para></para> tags as a way to group the text and add the blank line after it, but there is no equivalent to <br /> or anything like that. (Which according to this old MS forum post is by design.) You can get the list of available tags in this documentation article from MS. Documenting your code

Example (based on original OP sample):

/// <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>
慕烟庭风 2024-12-09 08:36:53

从 Visual Studio 2019 开始,使用
作为注释中的换行符。

示例:

/// <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>

Image Visual Studio 2019 工具提示中显示的摘要,其中在摘要文本中添加每个 HTML 中断标记的位置显示换行符

请注意,当我们使用
而不是

As of Visual Studio 2019, use <br/> for newlines in comments.

Example:

/// <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>

Image of summary appearing in Visual Studio 2019 tooltip, where line breaks are shown where each of the HTML break tags are added in the summary text

Notice that there is no extra line added when we use <br/> instead of <para>.

挽清梦 2024-12-09 08:36:53

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

/// <summary>
/// Value: 0/1/2
/// <para/>0 foo,
/// <para/>1 bar,
/// <para/>2 other
/// </summary>

This is my usage, like <br/> , it's working :)

/// <summary>
/// Value: 0/1/2
/// <para/>0 foo,
/// <para/>1 bar,
/// <para/>2 other
/// </summary>
紫﹏色ふ单纯 2024-12-09 08:36:53

添加一个 标记,其中包含特殊字符、255 个字符或 不可见字符

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

它将像这样工作:

在此处输入图像描述

Add a <para> tag with a special char in it, the 255 char, or invisible char.

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

It will work like this:

enter image description here

救星 2024-12-09 08:36:53


似乎不起作用,有时它并不是真正关于制作 < ;para> 句子之间的分隔程度与希望有一个空行来分隔关注点一样多。我在这里提到这一点是因为这个问题似乎是许多此类性质的封闭问题的根源。

我发现唯一有效的方法是

<para> </para>

例如

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

结果

"This sentence shows up when the type is hovered"

int PrimaryKey

virtual Relation Relation

<br></br> and <br /> do not seem to work, and sometimes it isn't really about making the <para> sentences separate as much as the desire to have a blank line for concern separation. I am mentioning this here because this question seems to be to parent to many closed questions of this nature.

The only thing I found to work was

<para> </para>

For example

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

Results in

"This sentence shows up when the type is hovered"

int PrimaryKey

virtual Relation Relation
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文