开发者

Are there some obvious disadvantageous of using 'regions'? [duplicate]

This question already has answers here: Closed 11 years ago.

P开发者_StackOverflow中文版ossible Duplicate:

Do you say No to C# Regions?

Is there any obvious disadvantageous of using 'region' pre-processor directives from the coding point of view?

 #region name
     // some code block
 #end region


I find that regions help organize code into logical sections. I've seen many examples from respected coders that regularly use regions. As far as I'm aware, it's purely cosmetic, and doesn't impact anything.


I wouldn't say say there are any disadvantages at all, if they are used as they are intended. The idea of them is to logically separate sections (regions) of code.

However, if they are deeply nested or methods are put outside of a region in which they would make sense, things could get confusing.


One gotcha to be aware of is that if the region is closed, Visual Studio "Find in current document" will not search through this region.

Find in Solution, or Find in Project will find it however.


I can't see any. There are few things to keep in mind though: It is not an excuse to have too many lines on your page (like a form with 2000 lines. That's plain bad, even with regions, because it means you are mixing the logic layers).

I personnaly like to use regions, but some people prefer to see their whole code. It's only about preference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜