C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Tip: You can optionally specify an identifier for the region, such as with #region FIELDS.
And: When you compile this program, the #region directives do not affect the intermediate language output.
ConsoleC# program that uses region directives
using System;
#region
class Example
{
}
#endregion
class Program
{
#region FIELDS
int _field1;
int _field2;
#endregion
static void Main()
{
#region BODY
Console.WriteLine("Hello world!");
Console.WriteLine("How are you today?");
#endregion
}
}
Output
Hello world!
How are you today?
Tip: To collapse a region, click the plus-minus sign on the left margin of Visual Studio next to your code.