Jaa


The #Region Directive

Organizing the IDE is one of the most important areas of productivity. The #Region directive allows you to organize your code into collapsible blocks of code which helps to make viewing code easier by displaying only those functions you are working with. Each region can be defined with a name that helps to identify it.

For example, assume that you have the following code in a Windows form. By default, the IDE already contains some built in regions that can be used to collapse code as shown below

 

When these are selected you can collapse your code down as shown below.

If you wanted to further customize these you could add your own regions as shown below.

When collapsed the code then looks like the following

Comments

  • Anonymous
    May 20, 2006
    Organizing the IDE is one of the most important areas of productivity. The #Region directive allows you...
  • Anonymous
    May 20, 2006
    In practice, I don't find this to be especially helpful.  When I am working with the code, I find that I am having to continually expand and collapse regions to find what I'm looking for.  I think it is a little distracting.
  • Anonymous
    May 21, 2006
    I think #Region is a nice idea but, c# and vb need to take a page from c++ ide and collapse based on scope, its much simpler to read code when you can fold a for loop or if statement.
  • Anonymous
    May 22, 2006
    I am a big fan of regions, I think it spoiled me though because the other day I was wishing I could region my web.config file...