#region/#endregion vs sub functions?

c#, visual-studio

Solution

Not at all.

First of all, `#regions` are more a way of grouping many related functions/members into collapsible regions. They are not intended to structure a single multi-thousand line function into parts. (That being said, if you write a single method that's so long that you consider structuring it with `#region`s then you're probably doing something seriously wrong. Regions or not, that code would be unmaintainable. Period.)

Many people argue however, that it doesn't really help and that you should consider rewriting classes that actually need regions to be understandable. Also, regions tend to hide nasty code.

Problem

How do you recommend using #region / #endregion? To what extent should that replace using sub functions to clarify your code?

Original source