各种编程语言的注释符

114 篇文章 8 订阅

常见语言:

c
行注释:none
块注释:
扩展名:.c/.h


c++

行注释://这里是注释
块注释:
扩展名:.cpp/.h


c#
行注释://这里是注释
块注释:
xml注释:///这里是xml注释
扩展名:.cs


vb
行注释:'这里是注释
块注释:none
扩展名:.bas


java
行注释://这里是注释
块注释:
扩展名:.java


vb.net
行注释:'这里是注释
块注释:none
xml注释:///这里是xml注释
扩展名:.vb


perl
行注释:#这里是注释
块注释:none
扩展名:.pm


html
行注释:none
块注释:<!--这里是注释-->
扩展名:.htm/.html
 
SQL
行注释:--
块注释:



Comment comparison

There is a wide variety of syntax styles for declaring comments in source code. BlockComment in italics is used here to indicate block comment style. InlineComment in italics is used here to indicate inline comment style.

LanguageIn-line commentBlock comment
AdaEiffelEuphoriaOccamSPARK, ANSI SQLToolBook OpenScript, and VHDL-- InlineComment 
ALGOL 60 comment BlockComment;
ALGOL 68 ¢ BlockComment ¢

comment BlockComment comment
co BlockComment co
BlockComment #
£ BlockComment £

AppleScript-- InlineComment(* BlockComment *)
Assembly language (varies)InlineComment   one example (most assembly languages use line comments only) 
AutoHotkeyInlineComment/* BlockComment */
AWKBashBourne shellC shellMaplePythonRTcl, and Windows PowerShellInlineComment<# BlockComment #>
BASIC (various dialects):'InlineComment (not all dialects)

REM InlineComment

 
C (K&R, ANSI/C89/C90), CHILLPL/I, and REXX /* BlockComment */
C (C99)C++Go, and JavaScript// InlineComment/* BlockComment */
C#// InlineComment
/// InlineComment (XML documentation comment)
/* BlockComment */
/** BlockComment */ (XML documentation comment)
CobolInlineComment (when * is in column 7) 
Curl|| InlineComment|# BlockComment #|

|foo# BlockComment #|

CobraInlineComment/# BlockComment #/ (nestable)
D// InlineComment
/// Documentation InlineComment (ddoc comments)
/* BlockComment */
/** Documentation BlockComment */ (ddoc comments)

/+ BlockComment +/ (nestable)
/++ Documentation BlockComment +/ (nestable, ddoc comments)

DCL$! InlineComment 
ECMAScript (JavaScriptActionScript, etc.)// InlineComment/* BlockComment */
ForthInlineCommentBlockComment ) (single line only)

before -- after ) stack comment convention

FORTRAN 66/77InlineComment (the letter 'C' in the first column makes the entire line a comment). 
Fortran 90InlineComment (all characters on the line, from the exclamation mark onwards, are comments) 
Haskell-- InlineComment{- BlockComment -}
Java// InlineComment/* BlockComment */

/** BlockComment */ (Javadoc documentation comment)

Lisp and SchemeInlineComment#| BlockComment |#
Lua-- InlineComment--[==[ BlockComment]==] (variable number of = signs)
MapleInlineComment(* BlockComment *)
Mathematica % (* BlockComment *)
MatlabInlineComment%{
BlockComment (nestable)
%}

Note: Both percent–bracket symbols must be the only non-whitespace characters on their respective lines.
Object Pascal (Delphi)// InlineComment(* BlockComment *)
BlockComment }
OCaml (* BlockComment (* nestable *) *)
PascalModula-2Modula-3Oberon, and ML: (* BlockComment *) (OCaml comments are nestable)
Perl and RubyInlineComment=begin
BlockComment
=cut
 (POD documentation comment)

__END__
Comments after end of code

PHPInlineComment
// InlineComment
/* BlockComment */
/** Documentation BlockComment */ (PHP Doc comments)
PILOTR:InlineComment 
PL/SQL and TSQL-- InlineComment/* BlockComment */
REALbasicInlineComment
// InlineComment
rem InlineComment
 
SAS BlockComment;
/* BlockComment */
Seed7InlineComment(* BlockComment *)
Simula comment BlockComment;
BlockComment;
Smalltalk "BlockComment"
Smarty {* BlockComment *}
Standard ML (* BlockComment *)
TeXLaTeXPostScriptErlang, and S-LangInlineComment 
Texinfo@c InlineComment

@comment InlineComment

 
TUTORInlineComment
command $$ InlineComment
 
Visual BasicInlineComment
Rem InlineComment
 
Visual Basic .NETInlineComment

''' InlineComment (XML documentation comment)
Rem InlineComment

 
Visual PrologInlineComment/* BlockComment */



参考推荐:

Comparison of programming languages (syntax)  (wiki)


  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
《Ruby编程语言》详细介绍了Ruby1.8和1.9版本各方面的内容。在对Ruby进行了简要的综述之后,《Ruby编程语言》详细介绍了以下内容:Ruby的句法和语法结构,数据结构和对象,表达式和操作,语句和控制结构,方法、proc、lambda和闭包,反射和元编程,Ruby平台。本书还包含对Ruby平台上丰富的API的详尽介绍,并用带有详尽注释的代码演示了Ruby进行文本处理、数字运算、集合、输入/输出、网络开发和并发编程的功能。  前言1   第1章导言1   1.1漫游RUBY2   1.2体验RUBY11   1.3关于本书15   1.4一个RUBY版的SUDOKU解答17   第2章RUBY程序的结构和运行25   2.1词法结构26   2.2句法结构33   2.3文件结构35   2.4程序的编码36   2.5RUBY程序的运行39   第3章数据类型和对象41   3.1数字42   3.2文本46   3.3数组64   3.4哈希67   3.5范围68   3.6符号71   3.7TRUE、FALSE和NIL72   3.8对象72   第4章表达式和操作85   4.1字面量和关键字字面量86   4.2变量引用87   4.3常量引用88   4.4方法调用89   4.5赋值92   4.6操作100   第5章语句和控制结构117   5.1条件式118   5.2循环127   5.3迭代器和可枚举对象130   5.4代码块140   5.5改变控制流146   5.6异常和异常处理154   5.7BEGIN和END165   5.8线程、纤程和连续体166   第6章方法、PROC、LAMBDA和闭包175   6.1定义简单方法177   6.2方法名180   6.3方法和圆括号183   6.4方法参数185   6.5PROC和LAMBDA192   6.6闭包200   6.7METHOD对象203   6.8函数式编程205   第7章类和模块213   7.1定义一个简单类214   7.2方法可见性:PUBLIC、PROTECTED、PRIVATE232   7.3子类化和继承234   7.4对象创建和初始化241   7.5模块247   7.6加载和请求模块252   7.7单键方法和EIGENCLASS257   7.8方法查找258   7.9常量查找261   第8章反射和元编程265   8.1类型、类和模块266   8.2对字串和块进行求值268   8.3变量和常量271   8.4方法272   8.5钩子方法277   8.6跟踪279   8.7OBJECTSPACE和GC281   8.8定制控制结构281   8.9缺失的方法和常量284   8.10动态创建方法287   8.11别名链290   8.12领域特定语言296   第9章RUBY平台303   9.1字串304   9.2正则表达式310   9.3数字和数学运算321   9.4日期和时间325   9.5集合328   9.6文件和目录350   9.7输入/输出356   9.8网络366   9.9线程和并发372   第10章RUBY环境389   10.1执行RUBY解释器390   10.2顶层环境394   10.3实用性信息抽取和产生报表的快捷方式403   10.4调用操作系统的功能405   10.5安全409
### 回答1: 在Java中,注释注释内容之间的空格通常是可选的,即可以有空格,也可以没有空格。这是因为Java编译器会忽略注释中的空格,不会对代码产生影响。因此,注释注释内容之间是否有空格可以根据个人喜好和团队规范来决定。 不过,有些开发人员认为注释注释内容之间不应该有空格,因为这样可以让注释更加紧凑、易读。另外,一些开发工具也会自动去除注释注释内容之间的空格,以保持代码的风格一致性。 例如,下面是没有空格的注释示例: ```java //计算两个整数的和 public int add(int a, int b) { return a + b; } ``` 下面是有空格的注释示例: ```java // 计算两个整数的和 public int add(int a, int b) { return a + b; } ``` 无论采用哪种方式,注释的内容应该简明扼要、易于理解,以提高代码的可读性和可维护性。 ### 回答2: 注释是一种用于在代码中添加注释的特殊字。它的作用是对代码进行解释说明,提供一个易于理解和维护的文档。注释内容是在注释后面写的,用于描述代码的功能、用途、逻辑以及其他相关信息。 注释的常见类型有单行注释和多行注释。单行注释以特定字(如"//")开头,表示其后面的内容为注释。它通常用于注释单行代码或单行代码片段。多行注释以一对特定字(如"/*"和"*/")包裹起来,表示其中的内容为注释。它通常用于注释多行代码、代码块或较长的代码片段。 注释内容应该紧跟在注释后面,两者之间不应该有空格。这是为了保持注释的整洁和易读性。在编写注释时,应该注意避免过度注释或无用注释,以免干扰代码的阅读和理解。 注释的作用在于增强代码的可读性和可维护性。它可以帮助其他开发人员理解代码的意图和逻辑,减少代码的潜在错误和风险。注释还可以方便代码的调试和修改,以及提供文档和参考信息。 总之,注释注释内容之间不应该有空格。注释应该简明扼要地描述代码的功能和用途,有助于提高代码的可读性和可维护性。 ### 回答3: 注释注释内容通常不应该有空格。 在计算机编程中,注释(或注释标记)是一种用于添加注释或说明的特殊字或字串。它们帮助程序员向代码添加注释,以解释代码的功能、目的或任何其他相关信息。 常见的注释包括双斜杠(//)和斜杠星号(/* */)。使用双斜杠时,注释后的所有内容都被视为注释,直到本行结束。使用斜杠星号时,注释之间的所有内容都被视为注释注释内容通常用于解释代码的意图、算法步骤、变量用途和其他相关信息。它们对于代码的可读性和可维护性非常重要。程序员可以使用注释来提供代码的文档,以便其他开发人员可以理解和修改代码。 在书写注释时,应注意注释注释内容之间不应该有空格。这是因为编程语言在解析代码时不会忽略空格。如果注释注释内容之间有空格,编译器或解释器将无法正确解释代码,并可能导致错误。 总之,在编写代码时,应确保注释注释内容之间没有空格,以确保代码的正确性和可读性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值