Comments ใช้สำหรับอธิบายโค้ด คอมไพเลอร์จะละเว้น comments
Multi-line Comments (หลายบรรทัด)
/* The following is a multi-line comment In C# */
Single-line Comments (บรรทัดเดียว)
// variable int a = 10;
ตัวอย่างโปรแกรม
using System;
namespace HelloWorldApplication {
class HelloWorld {
static void Main(string[] args) {
/* I have started learning C# and
this is my first program */
// displaying text
Console.WriteLine("Learn C# now!");
Console.ReadKey();
}
}
}
ผลลัพธ์
Learn C# now!