Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Putting "using" at the top of the files is the default way of Visual Studio. However, the recommended approach is putting the "using" statements inside of the namespace. Even MS's stylecop catches this and says the default way of VS is wrong. </p> <p>Both techniques work fine.</p> <blockquote> <p><strong>StyleCop Rule says:</strong> Placing multiple namespace elements within a single file is generally a bad idea, but if and when this is done, it is a good idea to place all using directives within each of the namespace elements, rather than globally at the top of the file. This will scope the namespaces tightly, and will also help to avoid the kind of behavior described above.</p> <p>It is important to note that when code has been written with using directives placed outside of the namespace, care should be taken when moving these directives within the namespace, to ensure that this is not changing the semantics of the code. As explained above, placing using-alias directives within the namespace element allows the compiler to choose between conflicting types in ways that will not happen when the directives are placed outside of the namespace.</p> </blockquote> <p>Here's some links for further review:</p> <ul> <li><a href="https://stackoverflow.com/questions/125319/should-usings-be-inside-or-outside-the-namespace">Should &#39;using&#39; statements be inside or outside the namespace?</a></li> <li><a href="https://stackoverflow.com/questions/1071797/is-sa1200-all-using-directives-must-be-placed-inside-the-namespace-stylecop-pur">Is sa1200 All using directives must be placed inside the namespace (StyleCop) purely cosmetic?</a></li> <li><a href="http://www.hanselman.com/blog/BackToBasicsDoNamespaceUsingDirectivesAffectAssemblyLoading.aspx" rel="nofollow noreferrer">http://www.hanselman.com/blog/BackToBasicsDoNamespaceUsingDirectivesAffectAssemblyLoading.aspx</a></li> <li><a href="http://blogs.msdn.com/sourceanalysis/pages/sa1200-usingdirectivesmustbeplacedwithinnamespace.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/sourceanalysis/pages/sa1200-usingdirectivesmustbeplacedwithinnamespace.aspx</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload