1.C#中的註釋符

1.軟件行業的道德規範
(1).程序員在平常寫代碼的過程當中,必定要養成註釋的好習慣,方便後面對理解和使用.
(2).在給標識符命名的時候必定要規範,有理有據的,名字不能瞎寫.

2.註釋
註釋符的做用:
(1).註釋須要解釋的代碼
(2).註銷掉代碼,就是將不想參與執行的代碼註銷

C#語言中包含了三種註釋符
(1).單行註釋   //
(2).多行註釋  /*要註釋的內容*/       注意:多行註釋不能嵌套使用
(3).文檔註釋 ///     文檔註釋能夠用來註釋方法,也能夠用來註釋類.

單行註釋符   //
   
   
   
   
  1. //這行代碼的做用是將程序暫停在這個地方.
class Program { static void Main(string[] args) { //這一行代碼的做用是將hello world打印到控制檯中 Console.WriteLine("Hello world"); // Console.WriteLine("不想輸出的代碼"); 此行代碼被註銷了 Console.ReadKey(); } }

多行註釋  /**/
   
   
   
   
class Program { static void Main(string[] args) { /*如下是不想要的代碼 Console.WriteLine("Hello world"); Console.WriteLine("Hello world"); Console.WriteLine("Hello world"); Console.WriteLine("Hello world"); Console.WriteLine("Hello world"); Console.WriteLine("Hello world"); Console.WriteLine("Hello world"); Console.WriteLine("Hello world"); */ Console.ReadKey(); } }

文檔註釋  ///
   
   
   
   
class Program { static void Main(string[] args) { Console.WriteLine("Hello world"); Console.ReadKey(); } /// <summary> /// 這個方法的做用就是求兩個整數之間的最大值 /// </summary> /// <param name="n1">第一個整數</param> /// <param name="n2">第二個整數</param> /// <returns>返回比較大的那個數字</returns> public static int GetMax(int n1, int n2) { return n1 > n2 ? n1 : n2; } } /// <summary> /// 這個類用來描述一我的的信息 從姓名 性別 年齡 描述 /// </summary> public class Person { public string Name { get; set; } public int Age { get; set; } public char Gender { get; set; } }





相關文章
相關標籤/搜索