C# using namespace directive in nested namespaces

Posted by MoSlo on Stack Overflow See other posts from Stack Overflow or by MoSlo
Published on 2010-01-08T09:02:44Z Indexed on 2010/04/01 2:23 UTC
Read the original article Hit count: 548

Right, I've usually used 'using' directives as follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AwesomeLib
{
  //awesome award winning class declarations making use of Linq
}

i've recently seen examples of such as

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AwesomeLib
{
  //awesome award winning class declarations making use of Linq

  namespace DataLibrary
  {
    using System.Data;

    //Data access layers and whatnot
  }

}

Granted, i understand that i can put USING inside of my namespace declaration. Such a thing makes sense to me if your namespaces are in the same root (they organized).

System;
namespace 1 {}
namespace 2 
{
  System.data;
}

But what of nested namespaces? Personally, I would leave all USING declarations at the top where you can find them easily. Instead, it looks like they're being spread all over the source file.

Is there benefit to the USING directives being used this way in nested namespaces? Such as memory management or the JIT compiler?

© Stack Overflow or respective owner

Related posts about c#

Related posts about namespaces