这个问题似乎还没有被问到。如果重复,请评论。
也就是说,我在C#代码中有#region注释。
#region if this comment is very long, can I divide the comment into multi-lines?
// my code is here
#endregion是否可以像底部代码一样将#region注释分成多行?
#region the comment is separated into
#region-2 two lines.
// my code is here
#endregion发布于 2012-11-16 12:21:44
我不认为长注释是#region指令的预期用途。当我想到"region“时,我会想到”私有成员“、”服务声明“、”重载构造函数“或类似的简单标签。
如果你有一个很长的评论,我会把它放在区域的顶部,如下所示:
#region Some Region Name
/**
* Here is a decently lengthy comment which describes the
* group of class members within the region.
*/
/// <summary>
/// A regular member's comment documentation.
/// </summary>
public int MyRegionProperty { get; set; }
// etc...
#endregionMSDN将#region后面的部分描述为“名称”,而不是注释。名称应该具有足够的描述性,以识别区域中的内容,仅此而已。
发布于 2012-11-16 12:25:28
来自MSDN的#Region的定义
`#region允许您指定在使用Visual Studio代码编辑器的大纲功能时可以展开或折叠的代码块。在较长的代码文件中,可以折叠或隐藏一个或多个区域,以便您可以专注于当前正在处理的文件部分。
它的主要用途是允许概述您的代码,并能够折叠区域(区域)以提高可读性。如果需要扩展注释,则必须使用标准C#注释
发布于 2012-11-16 12:29:48
Region用于对代码块进行分组,这些代码块可以展开和折叠,不能用于注释:

浏览此http://www.dotnetperls.com/region
https://stackoverflow.com/questions/13410310
复制相似问题