ECMA-334 C# Language Specification

9.3.2: Comments

Two forms of comments are supported: delimited comments and single-line comments.

A delimited comment begins with the characters /* and ends with the characters */. Delimited comments can occupy a portion of a line, a single line, or multiple lines. [Example: The example
/* Hello, world program  
This program writes "hello, world" to the console  
*/  
class Hello  
{  
   static void Main() {  
      System.Console.WriteLine("hello, world");  
   }  
}  
includes a delimited comment. end example]

A single-line comment begins with the characters // and extends to the end of the line. [Example: The example
// Hello, world program  
//   This program writes "hello, world" to the console  
//  
class Hello // any name will do for this class  
{  
   static void Main() { // this method must be named "Main"  
      System.Console.WriteLine("hello, world");  
   }  
}  
shows several single-line comments. end example]

single-line-comment
delimited-comment
single-line-comment
// input-charactersopt
input-character
input-character
input-characters input-character
input-character
Any Unicode character except a new-line-character
new-line-character
Carriage return character (U+000D)
Line feed character (U+000A)
Line separator character (U+2028)
Paragraph separator character (U+2029)
delimited-comment
/* delimited-comment-charactersopt */
delimited-comment-character
delimited-comment-character
delimited-comment-characters delimited-comment-character
delimited-comment-character
not-asterisk
* not-slash
not-asterisk
Any Unicode character except *
not-slash
Any Unicode character except /

Comments do not nest. The character sequences /* and */ have no special meaning within a single-line comment, and the character sequences // and /* have no special meaning within a delimited comment.

Comments are not processed within character and string literals.