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!

更新於:20-Jun-2020

179 次瀏覽

開啟你的職業

完成課程獲得認證

開始學習
廣告
© . All rights reserved.