1

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
  }
}
cpoDesign
  • 8,953
  • 13
  • 62
  • 106
  • It might help [Should using be inside or outside][1] [1]: http://stackoverflow.com/questions/125319/should-usings-be-inside-or-outside-the-namespace – Asif Mushtaq May 21 '12 at 10:06

1 Answers1

0

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

HatSoft
  • 11,077
  • 3
  • 28
  • 43