Region Directive in AL
APPLIES TO: Business Central 2020 release wave 2 and later
#region directive is used to mark a block of code that you can expand or collapse. This can, for example, be useful for larger files for better readability or for focusing on code that you are currently working on. The
#endregion specifies the end of a
#region block of code.
On the first line of the
#region a text comment can be added to describe the purpose of the block of code, see the example below.
#region [comment] code
#region block must be terminated with 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
In this example the
#region directive makes a code block that is up for refactoring collapsible.
#region Ugly code - let's not look at this procedure UglyCode() begin // No one should look at this end; #endregion