Avoid Regions for Interfaces in Visual Studio

Another quick tip related to the use of regions in your C# code – you can turn off the default behavior of wrapping interfaced implementations in regions via the options dialog.  Simply go to Tools –> Options –> Text Editor –> C# –> Advanced as shown in the screenshot below, and uncheck the “Surround generated code with #region” checkbox.

image

6 Comments

  • DM said

    Thanks. I'm the same as John, I never thought to look around and fix it, just assumed I had to deal with it. Now I won't have to get annoyed and want to punch my screen anymore.

  • mario said

    Seems to me that in a +very+ few circumstances, regions might help, but in the general case, I think things like Goto Def, Navigate Back, and a sorted function list are much more effective.
    The only thing I might add is that I've always found that prefixing my Private members with "p" (or something) makes it MUCH easier for me to quickly see the "public" footprint of a class, and filter out the non-public stuff.

  • tunezja said

    In Visual Studio 2008 it was possible to open a collapsed #region by simply double clicking somewhere behind (to the right) of the #region. Now in VS 2010 you have to double click exactly the #region, double clicking behind it just selects the #region.
    Does anyone know of a way to switch back to the old behavior?

Add a Comment