C#
C#でソースコードにコメントを埋め込む
ソースコード中にコメントを埋め込みます。//は、//以降の文字列をコメントとして扱います。
//は、関数や変数への代入など、プログラム文の後ろに続けて書くことができます。
/* 〜 */は、囲まれた部分(〜)をコメントとして扱います。
/* */では複数行のコメントを書くことができます。
関数や変数への代入など、プログラム文の中に埋め込むこともできます。
/* */の中に/* */を入れ子にして書くことはできません。
Comment.cs
using System;
class Comment {
static void Main() {
// one line comment
Console.WriteLine("one line comment can write after statement\n"); // one line comment
/* This comment style can be written in multi lines like the following */
/*
line 1
line 2
*/
/* this comment style can be embedded in statement */
Console.WriteLine("This WriteLine statement line includes " /* comment */ + "comment\n");
}
}
実行結果
$ mcs Comment.cs
$ mono Comment.exe
one line comment can write after statement
This WriteLine statement line includes comment