Problem solve Get help with specific problems with your technologies, process and projects.

#region blocks are being put into my code by the VS.NET wizards, but I have no idea what they're for

#region blocks are being put into my code by the VS.NET wizards, but I have no idea what they're for. Help me!
Don't panic. The VS.NET code editor window knows how to collapse and expand certain regions of your code with little plus and minus signs in the margins. This feature is called outlining and allows you to, for example, collapse the entire implementation of one class while you're concentrating on another one. However, only certain constructs can be outlined, like classes, namespaces and methods.

For other things, like a group of event handler methods, you can define a custom group for outlining using a region, defined using the #region/#endregion directives. For example, the Implement Interface feature of VS.NET produces a region for the method implementations labeled " Methods." Collapsed, it looks like this:

class MyClass : IDisposable
       IDisposable Members

There are a number of operations that can be performed on a region of outlined code, as shown in the Edit -> Outlining menu:

  • Toggle Outline Expansion: Expand or collapse the current region.
  • Toggle All Outline: Expand or collapse the current file.
  • Stop Outlining: Turn off the outlining feature for all text files.
  • Collapse To Definitions: Hide all code and show just namespace, class and member definitions.
  • Dig Deeper on Dynamic .NET programming languages

    Have a question for an expert?

    Please add a title for your question

    Get answers from a TechTarget expert on whatever's puzzling you.

    You will be able to add details on the next page.

    Start the conversation

    Send me notifications when other members comment.

    Please create a username to comment.