Functions and Directives

Directive #region directive Foundation

Controls display of code in the source code editor

<%#region <your text>%>

The #region directive allows specifying a block of code that can be expanded or collapsed in the source code editor. By default, content embedded into a #region/#end directive is displayed collapsed and is not visible in the editor. Instead, only the text defined in <your text> is shown. This feature, called "code folding", can contribute significantly to source code readability.

A #region block cannot overlap with an #if block. However, a #region block can be nested in an #if block, and an #if block can be nested in a #region block.

The following screenshot illustrates the difference between code defined in a #region that is currently collapsed (folded away) and expanded.


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.