C# 中的註釋是什麼?


註釋用於解釋程式碼。編譯器會忽略註釋條目。C# 程式中的多行註釋以 /* 開頭,以 */ 結尾,如下所示。

多行註釋

/* The following is a mult-line
comment In C#
/*

編譯器會忽略 /*...*/,並在程式中插入註釋。

單行註釋

// variable
int a = 10;

以下是演示如何新增單行註釋和多行註釋的 C# 程式示例 −

示例

 線上演示

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();
      }
   }
}

輸出

Hello World

更新日期:2020 年 6 月 20 日

146 次瀏覽

開啟你的 職業生涯

完成課程即可獲得認證

開始
廣告
© . All rights reserved.