VS 2010 Tip Using Ad Hoc Regions
I really like the use of Regions within my code. They are a great way to organize and collapse section of code. Working with a large project like Kentico its a great way to organize and collapse code. Within Visual 2010, I found a new feature called ad-hoc regions that has been a big help to me. In this blog post we will cover how to use this feature within your code.
To create a standard region you enter #regions <name> and #endregion as shown below.
One concern is that this creates extra code lines and requires extra typing while you are debugging. Also, when you have a couple of people working on a project, they may not be interested in how I want to parse code for debugging. This is an area where ad hoc regions can come into play. In this example we will use the keyboard shortcuts. These are also available from the Edit -> Outlining menu as shown below
Lets create an ad hoc region using the following steps
1. Within the web project select a some code
2. Press <CTRL> + M + <CTRL> + H to collapse the code as shown below
3. If you hold the mouse over the collapsed block you can see the collapsed block as shown below
4. Press <CTRL> + M + <CTRL> + U to expand (You can also double click on the code block) as shown below