Surround generated code with #region while implement Interface

In Visual Studio you can enable and disabled the automatic #region code surround while implement interface. Well by default it’s set to off and which is mostly like by all developer. But if you want some change, and you want while implementing interface it should automatically surround by #region then you have to go to Tools > Options > Text Editor > C# > Advanced.

By default it will be un-checked.

image

So when it’s unchecked, if you implement any interface you wont be able to find any #region surround with your implemented interface. This is now by default features.

image

Now, if you want some changes and want your interface to warp with #region automatically, just check the “Surround Generated Code With #region”

image

Once the above settings set, you will find your while implementing a new interface your code block surrounding with #region with Interface name

image

Now, if you are implementing multiple interface with same settings you will find you have multiple #region surrounding with different interface.image

Well, as I said, by default in Visual Studio it’s turned off, as most of the time we don’t want the automatic region snippet surrounding with interface name or we may need a single region tag for all the interface. So, it’s totally depends on you how you want to use it.

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.