Using operators before or after Namespace in C #

Possible duplicate:
If use should be inside or outside the namespace

So, there are two approaches to where you have your use statements with respect to the namespace. You can either use them outside the namespace declaration, or inside. What is pro / con between the two approaches and which is usually preferable.

using System; namespace MyNamespace { } 

or

 namespace MyNamespace { using System; } 
+4
source share
1 answer

Usually I see the first one being used. These operators are usually at the very beginning of the source file, making it easy to see what a particular file is using. It also allows you to easily see the start of a new code, as the namespace signals new material.

Another way is a little less easy to follow from an organizational point of view. The only advantage is that you can have different using statements in two different namespaces in the same file, but using two namespaces in the same place like this is bad coding practice, so it should be avoided.

+3
source

All Articles