XML在C#中多行注释 - 我究竟做错了什么? [英] XML multiline comments in C# - what am I doing wrong?
问题描述
根据这篇文章,有可能获得多行XML注释 - 而不是使用 ///
,使用 / ** * /
。这是一个什么样多行注释是我跨pretation,什么我想有发生:
/ **
*<总结>
*此评论是在第1行中的提示
*此评论是第2行中的提示
*< /总结>
* /
然而,当我使用这种形式,当我将鼠标悬停在我的课的名字在我的code弹出的提示是单行,即它看起来完全一样,如果我写我的意见是这样的:
///<总结>
///此评论是在第1行中的提示
///此评论是第2行中的提示
///< /总结>
这是行为实际上可能仍然在VS2008?
修改
加布指出,我误会了多行的意思,而我真正需要使用<第>
或< BR>
来得到我预期的效果。我继续使用< BR>
,因为我想控制换行发生在哪里,即
///<总结>
///此评论是在提示&LT线1条; BR />
///此评论是在提示&LT线2条; BR />
///< /总结>
当我看着提示这个类在我的code,一切仍然在同一行...... WTH结束了?难道我做错了吗?
更新
好吧,我继续尝试<&款GT;每行
标签的作品。不知道为什么< BR /方式>
不
///<总结>
///<段>这评论是在工具提示和LT线1条; /对>
///<段>这评论是在工具提示和LT线2条; /对>
///< /总结>
这听起来像你无所适从多行的意思。单行注释源头code的行末结束,如果你想继续这样评论,你必须把/// 下一行。多行注释以a开头
/ *
,并着有 * /
,所以它可以结束结束无论是在同一行或多个行向下
作为多行只字未提任何如何在注释中的文本显示。为了把一个换行符在XML注释必须插入< BR />
(破发),或者换行的&LT ;第方式>
(段落)标签
According to this article, it's possible to get multiline XML comments -- instead of using ///
, use /** */
. 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, i.e. 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?
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. I went ahead and used <br>
because I want to control where the line breaks occur, i.e.
/// <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? Did I do something wrong here?
UPDATE
Ok, I went ahead and tried the <para>
tag on each line, and that works. Not sure why <br/>
doesn't.
/// <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在C#中多行注释 - 我究竟做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!