简体   繁体   English

C#中的XML多行注释 - 我做错了什么?

[英]XML multiline comments in C# - what am I doing wrong?

According to this article , it's possible to get multiline XML comments -- instead of using /// , use /** */ . 根据这篇文章 ,可以获得多行XML注释 - 而不是使用/// ,使用/** */ This is my interpretation of what multiline comments are, and what I want to have happen: 这是我对多行注释的解释,以及我想要发生的事情:

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

However, when I use this form, the tooltip that pops up when I hover over my class name in my code is single-line, ie it looks exactly as if I had written my comment like this: 但是,当我使用这个表单时,当我将鼠标悬停在我的代码中时弹出的工具提示是单行的,即它看起来就像我写了这样的评论:

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

Is this behavior actually possible still in VS2008? 这种行为实际上是否仍然可以在VS2008中使用?

EDIT 编辑

gabe pointed out that I have misunderstood what "multiline" means, and I actually need to use <para> or <br> to get my intended effect. gabe指出我误解了“多线”的含义,我实际上需要使用<para><br>来达到预期的效果。 I went ahead and used <br> because I want to control where the line breaks occur, ie 我继续使用<br>因为我想控制换行的位置,即

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

When I look at the tooltip for this class in my code, everything still ends up on one line... WTH? 当我在我的代码中查看此类的工具提示时,所有内容仍然会在一行中结束... WTH? Did I do something wrong here? 我在这里做错了吗?

UPDATE UPDATE

Ok, I went ahead and tried the <para> tag on each line, and that works. 好的,我继续在每一行上尝试<para>标签,这是有效的。 Not sure why <br/> doesn't. 不知道为什么<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>

It sounds like you are confused about what "multi-line" means. 听起来你对“多线”意味着什么感到困惑。 A single-line comment ends at the end of the line of source code, and if you want to continue that comment you must put a " /// " on the next line. 单行注释在源代码行的末尾结束,如果要继续该注释,则必须在下一行添加“ /// ”。 A multi-line comment starts with a " /* " and ends with a " */ " so it can end either on the same line or multiple lines down. 多行注释以“ /* ”开头,以“ */ ”结尾,因此它可以在同一行或多行中结束。

Being "multi-line" says nothing about any how the text within the comment is displayed. 作为“多行”,没有说明评论中的文本是如何显示的。 To put a line break in an XML comment you must insert a <br/> ("break") or wrap the line in a <para> ("paragraph") tag. 要在XML注释中添加换行符,必须插入一个<br/> (“break”)或将该行包装在<para> (“paragraph”)标记中。

Try this 尝试这个

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

Add <br/> for line breaks or enclose the paragraphs in <para>...</para> . 添加<br/>用于换行符或将段落括在<para>...</para> It's just like XML and HTML, the line break is nothing but whitespace. 就像XML和HTML一样,换行符只不过是空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM