Export (0) Print
Expand All
5 out of 8 rated this helpful - Rate this topic

#region (C# Reference)

#region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor. In longer code files, it is convenient to be able to collapse or hide one or more regions so that you can focus on the part of the file that you are currently working on. The following example shows how to define a region:

#region MyClass definition
public class MyClass 
{
    static void Main() 
    {
    }
}
#endregion

A #region block must be terminated with a #endregion directive.

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

Show:
© 2014 Microsoft. All rights reserved.