Question: **Note**: This "feature" has now been added to Visual Studio 2015 but the question will hold a while since not every developer or every dev shop gets access to the latest and greatest IDE as soon as it comes out.

**ORIGINAL QUESTION:**

Normally I wouldn't "need" or even consider a ridiculous feature such as code regions within method bodies but: I'm refactoring VB.NET code where methods routinely run five hundred lines of code or more and the references are so tightly coupled that the code defies simple refactoring such as method extraction. 

And that's why I thought I would try regions within a method body. I just wanted to organize the code for the short term. But the IDE doesn't let me (resulted in a compiler error.) I'm just curious as to why? Seems like code regions shouldn't impact the compiler, intellisense etc. Am I missing something? (Still using VS 2005 btw.)

**Interesting:** This seems to be language specific. It's OK in C# (I didn't check that initially) but not in VB.NET.

```
public module MyModule
    Sub RunSnippet()
        dim a as A = new A (Int32.MaxValue )

        #region 
        Console.WriteLine ("")
        #end region
       ....

```

that gets a compiler error but the C# version is ok.

Answer: 
Another simple alternative method:

What you can do is basically select the code you want to add the `#Region #End Region` and basically click:

`Ctrl`+`M`, `Ctrl`+`H`

This basically wraps the code. And then to make it even neater and easy to find you can comment the code. The end result would look something like this:

![enter image description here](https://i.stack.imgur.com/Q1WvH.png)
This was simply a choice the VB team made when adding the regions feature into version 7 of the Visual Basic language. It was seen as a feature which was useful for organizing at a declaration level and not inside a method and hence was allowed only at that level. 

The C# team felt differently about this feature and allow it in many other places. I've always found it surprising that C# `#region` directives can occur in different declaration contexts. 

```
#region Foo
class Bar {
#endregion

}

```

The equivalent code is not allowed in VB.