C# 注释块开始的星号数

Number of asterisks starting a C# comment block

在 Visual Studio 2010 年的 C# 程序中,我有一个以

开头的大型多行注释块

/**

评论区的一部分是一行,看起来像这样。 . .

this.afIODisplay = "<" + lineToParse + Environment.NewLine + this.afIODisplay;

在小于号处,颜色从注释绿色变为灰色,编译器发出警告说

XML comment on 'xxxxxxxxxxxxxxx' has badly formed XML -- 'A name was started with an invalid character.'

(xxxx 的替换专有代码标识符)为什么编译器试图将注释块解释为 XML?

作为实验,我尝试使用

转义小于号

&lt

但这并没有解决问题;它只是用一个新的

取代了警告

A name was started with an invalid character

并消除了向灰色的过渡。然后我用

替换了评论块的起始行

/*

问题消失了!!它也随着一整行星号而消失了。为什么星号的数量在 C# 注释中很重要?或者这只是一个 Visual Studio 错误?

C# 中的多行注释以 /* 开头 /** 用于 XML 评论

您在文档注释中 XML 格式不正确。这会根据规范生成警告。在 C# 5 规范的附录 A 中:

Comments having a special form can be used to direct a tool to produce XML from those comments and the source code elements, which they precede. Such comments are single-line comments that start with three slashes (///), or delimited comments that start with a slash and two stars (/**).

The text within documentation comments must be well formed according to the rules of XML (http://www.w3.org/TR/REC-xml). If the XML is ill formed, a warning is generated and the documentation file will contain a comment saying that an error was encountered.