C# using namespace directive in nested namespaces
- by MoSlo
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?