주석은 코드를 설명하는 데 사용됩니다. 컴파일러는 주석 항목을 무시합니다. C# 프로그램의 여러 줄 주석은 아래와 같이 /*로 시작하여 */ 문자로 끝납니다.
여러 줄 주석
/* The following is a multi-line comment In C# /*
/*...*/는 컴파일러에서 무시되며 프로그램에 주석을 추가하기 위해 배치됩니다.
한 줄 주석
// variable int a = 10;
다음은 한 줄 및 여러 줄 주석을 추가하는 방법을 보여주는 샘플 C# 프로그램입니다. −
예시
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!