C# 中的註釋
註釋用於解釋程式碼。編譯器會忽略註釋條目。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!
廣告