Comments dùng để giải thích code. Compiler bỏ qua comment entries. Multi-line comments bắt đầu bằng /* và kết thúc bằng */ như sau:
Multi-line comments
/* The following is a multi-line comment In C# /*
/*...*/ bị compiler bỏ qua, dùng thêm chú thích vào chương trình.
Single line comments
// variable int a = 10;
Ví dụ chương trình C# minh họa single-line và multi-line comments:
Ví dụ
using System;
namespace Demo {
class Program {
static void Main(string[] args) {
/* I have started learning C# and
is my first program */
// displaying text
Console.WriteLine("Hello World");
Console.ReadKey();
}
}
}
Kết quả
Hello World