c#中///和#region的区别

Vir*_*ren 8 c#

///和#region ...#endregion在c#中的注释语句有什么区别?哪一个最好?

T.J*_*der 36

#region根本不是评论声明.它用于标记代码段.///用于文档注释.


Ken*_*art 23

/// <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
Run Code Online (Sandbox Code Playgroud)

  • +1 ...和四个斜杠////是标记用于评论实际代码行的标准,其中/**/将不起作用(并停止ReSharper对此抱怨:) (2认同)

Num*_*man 5

#region使您的代码可读/可维护/更有组织的
///文档代码!