Skip to content

Visual Studio Tip: No Regions Around Implemented Interfaces

2009 September 10
by stefanoricciardi

One of the (many) useful features of Visual Studio is the Implement Interface. With it, if you declare a class as implementing a particular interface, you can have Visual Studio generate stubs for all the methods declared by that interface.

Visual Studio Implement Interface

With default settings, Visual Studio will place regions around the stubs that it just generated:

Visual Studio putting regions around implemented interfaces

As you may know from previous posts, I am not a fan of using regions within C# code. I tend to favor lean classes and short methods, I find regions almost useless; worse, they tend to visually clutter the code.

Luckily, there’s a way to configure Visual Studio not to put regions around implemented interfaces. It’s buried under Tools->Options->Text Editor->C#->Advanced. Simply uncheck the “Surround generated code with #region” in the “Implement interface” group:

Configuring Visual Studio to remove regions around interfaces

Voilà. You now have all your stubs ready to be implemented, without those annoying regions around:

Interfaces implemented without regions around

Bookmark and Share

Technorati Tags: ,
  • Tamir Shlomi

    Nice one!

  • http://openid-provider.appspot.com/GuiSim GuiSim

    Thanks for this.
    Quick, to the point and very useful.

  • Shane Fulmer

    Thanks! Wanted to figure out how to do this for a long time, but kept putting it off!

0 visitors online now
0 guests, 0 bots, 0 members
Max visitors today: 0 at 12:02 am CET
This month: 0 at 02-01-2012 12:00 am CET
This year: 48 at 01-13-2012 02:02 pm CET
All time: 82 at 01-24-2011 04:41 pm CET