Code folding in MonoDevelop with #region and #endregion
The two preprocessor directives #region
and #endregion
(in combination with the code folding feature) can be highly useful for improving the readability of your code and also for improving the speed with which you can navigate the source file. They add organization and structure to your source code without affecting its validity or execution. Effectively, #region
marks the top of a code block and #endregion
marks the end. Once a region is marked, it becomes foldable, that is, it becomes collapsible using the MonoDevelop
code editor, provided the code folding feature is enabled. Collapsing a region of code is useful for hiding it from view, which allows you to concentrate on reading other areas relevant to your needs, as shown in the following screenshot:
Tip
To enable code folding in MonoDevelop
, select Options in Tools from the application menu. This displays the Options window. From here, choose...