tags:

views:

66

answers:

1

Possible Duplicate:
Should Usings be inside or outside the namespace

So there are two approaches to where you have your using statements in regard to the namespace. You can either have them outside the namespace declaration or inside. What is the pro/con between the two approaches and which is generally preferred.

using System;

namespace MyNamespace
{
}

or:

namespace MyNamespace
{    
      using System;                 
}
A: 

I typically see the former in use. These using statements are typically at the very top of a source file, making it easy to see at a glance what a particular file makes use of. It also allows you to easily see the start of new code, as the namespace signals the new stuff.

The other way is a little bit less easy to follow from an organizational standpoint. The only benefit is that you could have different using statements in two different namespaces in the same file, but using two namespaces in the same place like that is bad coding practice, so it should be avoided.

Wade Tandy