2010-09-20 66 views

回答

3

///用於XML註釋,而區域不用於評論,但用於將代碼段組合在一起。

2

/// - >可用於一些評論

#region ...#endregion - >可以被用於標記的代碼組特定的區域,易於reffer

#region MainMethod 

     /// <summary> 
     /// Comments 
     /// </summary> 
     static void Main() 
     { 
      //Your code 
     } 
     #endregion 
1

完全不同的東西,一個是用於評論/文檔,另一個用於隱藏代碼。

XML Comments(///)

#Region

19
/// <summary> 
/// Three forward slashes denote a documentation comment, which can be used in 
/// conjunction with documentation tooling to generate API documentation for 
/// your code. 
/// </summary> 

// two forward slashes denote a code comment, which you can use to provide 
// commentary within your code 

/* 
This style of comment is called a block comment, which can be used to easily 
comment out large blocks of text within your code 
*/ 

#region Some Region Name 

// the above region allows the developer to collapse/uncollapse everything 
// within it, as long as their IDE supports regions 
public void SomeMethod() 
{ 
} 

#endregion 
+2

+1 ...和四個斜槓////是註釋掉實際代碼行的標準,其中/ * * /不起作用(並停止ReSharper呻吟:) – 2010-09-20 13:02:32

1

///用來在你的代碼中插入XML註釋。 Xml註釋允許您從項目中構建一個輸出Xml文件: 稍後,Visual Studio將使用此文件向您顯示帶有插入註釋的智能感知工具提示。此外,您可以使用eit來構建自己的文檔。 從你的源代碼看這裏有關how to build documentation的文章Xml評論

#region用來組織你的代碼。

3

#region,使你的代碼可讀性/維護只有IDE內有用它理解它(VS),讓您可以摺疊或展開的代碼,每一個地區你#區/#endregion定義/多組織
///文件代碼!

0

一個區域用於摺疊大面積的代碼,//用於在計算機不讀取它的情況下添加註釋。

#region your large code 
loads of code in this area. 
#endregion 

//This is just a note that the computer won't read.