30

根据这篇文章,可以获得多行 XML 注释——而不是使用///,使用/** */。这是我对多行注释的解释,以及我想要发生的事情:

/**
 * <summary>
 * this comment is on line 1 in the tooltip
 * this comment is on line 2 in the tooltip
 * </summary>
 */

但是,当我使用此表单时,当我将鼠标悬停在我的代码中的类名上时弹出的工具提示是单行的,即看起来就像我写的评论是这样的:

/// <summary>
/// this comment is on line 1 in the tooltip
/// this comment is on line 2 in the tooltip
/// </summary>

这种行为实际上仍然可能在 VS2008 中吗?

编辑

gabe 指出我误解了“多行”的含义,我实际上需要使用<para><br>获得我想要的效果。我继续使用<br>,因为我想控制换行符发生的位置,即

/// <summary>
/// this comment is on line 1 in the tooltip<br/>
/// this comment is on line 2 in the tooltip<br/>
/// </summary>

当我在我的代码中查看该类的工具提示时,所有内容仍以一行结束... WTH?我在这里做错了吗?

更新

好的,我继续尝试了<para>每一行的标签,这很有效。不知道为什么<br/>不。

/// <summary>
/// <para>this comment is on line 1 in the tooltip</para>
/// <para>this comment is on line 2 in the tooltip</para>
/// </summary>
4

3 回答 3

20

尝试这个

/// <summary>
/// this comment is on line 1 in the tooltip
/// <para>this comment is on line 2 in the tooltip</para>
/// </summary>
于 2010-03-30T17:46:50.673 回答
17

听起来您对“多行”的含义感到困惑。单行注释在源代码行的末尾结束,如果您想继续该注释,您必须///在下一行添加一个“”。多行注释以“”开头,以“ /*”结尾,*/因此它可以在同一行或多行结束。

成为“多行”并没有说明评论中的文本是如何显示的。要在 XML 注释中放置换行符,您必须插入<br/>("break") 或将行换行在<para>("paragraph") 标记中。

于 2010-03-30T17:49:28.237 回答
2

添加<br/>换行符或将段落括在<para>...</para>. 就像 XML 和 HTML 一样,换行符只不过是空格。

于 2010-03-30T17:46:17.373 回答