如何在 C# 中編寫單行註釋?


如果您想新增一條註釋限制在單行中,那麼請使用單行註釋 −

// variable
int i = 20;

以下是一個展示如何新增單行註釋的 C# 程式示例 −

示例

 即時演示

using System;

namespace Demo {
   class Program {
      static void Main(string[] args) {

         // display text
         Console.WriteLine("Hello World");
         Console.ReadKey();
      }
   }
}

輸出

Hello World

更新於:2020 年 6 月 20 日

223 次瀏覽

開始你的 職業生涯

完成課程獲得認證

開始吧
廣告
© . All rights reserved.