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.