C# .NET // vs /// 注释约定

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/181015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 16:52:54  来源:igfitidea点击:

.NET // vs /// Comments convention

c#f#comments

提问by johnc

I am just checking out F#, so apologies if this is a silly question, but in the VS2008 F# CTP 1.9.6.2 'Tutorial' project, both // and /// are used for commenting code.

我只是在检查 F#,如果这是一个愚蠢的问题,我很抱歉,但在 VS2008 F# CTP 1.9.6.2 'Tutorial' 项目中,// 和 /// 都用于注释代码。

Is there a functional difference between the two slash vs three slash commenting, or is it convention (as it appears in the tutorial code) to comment a function with /// and use // for everything else?

两个斜杠与三个斜杠注释之间是否存在功能差异,或者是惯例(如教程代码中所示)使用 /// 注释函数并将 // 用于其他所有内容?

采纳答案by Franci Penov

Using three slashes (///) is a C# convention for XML Documentation Commentsthat is adopted by F# as well.

使用三个斜杠 (///) 是F# 也采用的XML 文档注释的 C# 约定。

回答by Alexander Kojevnikov

/// is for documentation comments. VS will use it when generating intellisense information.

/// 用于文档注释。VS 会在生成智能感知信息时使用它。

回答by Dean Rather

It's similar to /* comment */vs /** documented comment */in Java.

它类似于Java 中的/* comment */vs。/** documented comment */

The latter works the same, but is also recognised by documentation software to be developer documentation - not just a note.

后者的工作原理相同,但也被文档软件识别为开发人员文档 - 不仅仅是注释。

回答by P. Huhn

/// or ''' for C# and VB.Net are much more than internal comments. If one turns on XML documentation filein the project properties one can, then use Sandcastle and HTML Help to generate four different documentation type (files & web sites). See https://github.com/EWSoftware/SHFB/wikiand microsoft docs. Additional, this can be added to your CI process.

/// 或 ''' 对于 C# 和 VB.Net 不仅仅是内部注释。如果在项目属性中打开XML 文档文件,则可以使用 Sandcastle 和 HTML 帮助生成四种不同的文档类型(文件和网站)。请参阅https://github.com/EWSoftware/SHFB/wikimicrosoft docs。此外,这可以添加到您的 CI 流程中。