如何在.NET 中使用内联注释来记录成员?

发布于 2024-07-07 19:01:02 字数 235 浏览 3 评论 0原文

如何在 .Net 中内联记录成员? 让我解释。 大多数从注释中提取文档的工具都支持某种内联文档,您可以在成员声明后添加简短的内容。 比如:

public static string MyField; /// <summary>Information about MyField.</summary>

有没有办法用 C# 或 .NET 语言来做到这一点?

How can I document a member inline in .Net? Let me explain. Most tools that extract documentation from comments support some kind of inline documentation where you can add a brief after the member declaration. Something like:

public static string MyField; /// <summary>Information about MyField.</summary>

Is there a way to do this in C# or the .NET languages?

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

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

发布评论

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

评论(3

画▽骨i 2024-07-14 19:01:02

不,你不能。 XML 注释仅支持块级注释,这意味着它必须放置在您正在记录的代码元素之前。 从 .NET 代码中提取 XML 注释的常用工具不知道如何解析这样的内联注释。 如果您需要这种能力,您将需要编写自己的解析器。

No, you can't. XML comments are only supported as a block level comment, meaning it must be placed before the code element you are documenting. The common tools for extracting XML comments from .NET code do not understand how to parse inline comments like that. If you need this ability you will need to write your own parser.

雪化雨蝶 2024-07-14 19:01:02

没有内置的方法可以做到这一点。 XML文档系统是分层的; 它定义了标签

和紧随其后的数据之间的关系。

There is not a built-in way to do this. The XML documentation system is hierarchical; it defines a relationship between the tag <summary /> and the data that immediately follows it.

鹊巢 2024-07-14 19:01:02

是的,只需将其放在您要评论的内容之前即可

/// <summary>Information about MyField.</summary>
public static string MyField; 

Yep, just put it BEFORE the thing you want to comment

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