5

I've noticed some C# code has the using statements within the namespace instead of at the top of the file. For example, instead of this:

using System;
namespace SomeClassNameSpace
{
public class SomeClass 
{ }
}

They have this:

namespace SomeClassNameSpace
{
using System;
public class SomeClass 
{ }
}

Is this a matter of personal preference or is there a reason for having using statements inside or outside the namespace tag?

user2864740
  • 60,010
  • 15
  • 145
  • 220
Michael Shnitzer
  • 2,465
  • 6
  • 25
  • 34
  • 1
    It is a StyleCop rule, [SA1200: UsingDirectivesMustBePlacedWithinNamespace](http://www.stylecop.com/docs/SA1200.html) – Hans Passant May 24 '14 at 02:26

1 Answers1

-2

Well if you define classes or methods outside of that namespace within the same file then using System will be global for the whole file rather than just for the namespace.