Turn Off #region Tags When Implementing a C# Interface in Visual Studio 2010

comments

One of the most annoying things I find when i start working with a fresh installation of Visual Studio 2010 is that when implementing interfaces and base classes using the “Implement Interface X” function (CTRL + period) it inserts those crappy #region tags.

NOTE: Before you tell me how much you love having #regions dotted everywhere in your code, I'm going to tell you now i think you are an idiot – if your class has so many lines in it you need to hide things, you need to clear your sinuses as you’re missing the stench of code smell.

An Example of the crappy #region tags I'm talking about:

public interface ITestClass
{
    void RunFoo();
}
public class TestClass : ITestClass
{

    #region ITestClass Members

    public void RunFoo()
    {
        
} #endregion }
^ Somewhere Baby Jesus is crying… and the #region demons are licking their lips with glee 

Let’s fix it

Open Visual Studio 2010

Go to Tools > Options

image

Go to Text Editor > c# > Advanced

Un tick the box “Surround generated code with #region”

image

You are done!