How to use #region directive

Using #region directive

The #region and #endregion directives define a region that will be expanded or collapsed when using outlining in the Visual Studio IDE.

Syntax

The general form is shown here:


#region region-name 
 // code sequence
#endregion

Example

The following code shows how to use #region and #endregion.


using System;/*  ww w .  j av a 2  s . com*/

class MainClass
{
  [STAThread]
  static void Main(string[] args)
  {
      #region Stuff 
          
    
      #endregion

  }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    Custom Types »




C# Class
C# Struct
C# Interface
C# Inheritance
C# Namespace
C# Object
C# Delegate
C# Lambda
C# Event
C# Enum
C# Attribute
C# Generics
C# Preprocessor