ECMA-334 C# Language Specification9.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.
includes a delimited comment. end example]
/* Hello, world program
This program writes "hello, world" to the console
*/
class Hello
{
static void Main() {
System.Console.WriteLine("hello, world");
}
}
A single-line comment begins with the characters // and extends to the end of the line.
shows several single-line comments. end 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");
}
}
single-line-comment
delimited-comment
//
input-characters
opt input-character
input-characters
input-character
new-line-character
/*
delimited-comment-characters
opt */
delimited-comment-character
delimited-comment-characters
delimited-comment-character
not-asterisk
*
not-slash
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.