I have been wondering what is better way of using code.
Is there any difference between writing using inside of namespace:
ouside of namespace
using System.Data.Entity;
using System.Web.Mvc;
using System.Web.Routing;
using Myproject.DataLayer;
namespace Myproject
{
public class MyProjectClass{
// etc
}
}
Inside of namespace
the only reason i can thing of : shorter names, and the complier does not need to go to global location to find the implementation… but not sure about the rest
namespace Myproject
{
using System.Data.Entity;
using System.Web.Mvc;
using System.Web.Routing;
using DataLayer;
public class MyProjectClass{
// etc
}
}
Scott have already answered the question at http://www.hanselman.com/blog/BackToBasicsDoNamespaceUsingDirectivesAffectAssemblyLoading.aspx
Value of keeping the using code & Alias names inside namespace incase if you decide to have multiple namespaces in one file.
But the question to ask yourself is why do I want to have multiple namespace’s in the same file