BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Visual Studio
VS 2003+

Disabling #region when Implementing Interfaces

When using Visual Studio's Implement Interface command, the automatically added code is contained within a code region by default. As some developers prefer not to use code regions, it can be useful to disable this feature.

Implement Interface Regions

When using the default configuration and implementing an interface automatically, the newly added code is contained within a code region, between #region and an #endregion directives. For example, when you run the Implement Interface command for the IDisposable interface, the resultant code is similar to that shown below:

#region IDisposable Members

public void Dispose()
{
    throw new NotImplementedException();
}

#endregion

Some developers prefer not to use regions and will delete the two directives accordingly. You can, however, prevent the region being added by changing the Visual Studio settings. To do so, select Options from the Tools menu to display the Options dialog box. Expand the Text Editor and C# items in the tree structure and select the Advanced node. You can then uncheck the "Surround generated code with #region" option, shown below.

Visual Studio Implement Interface Regions

30 July 2010