Just wondering what the recommended practice is for importing namespaces. Are you always better importing the namespace like the fisrt snippet of code, or are you better to type the full namespace inline with your code.
I like both methods; the first is tidier and takes less code, the second can identify exactly where your accessing some logic from which can provide some clarity when looking over the code. Just wondering if there are pros/cons for either or if this is just a personal preference, currently I use a combination but would like to keep consistant.
Imports Core.Tech
Public SomeClass
Public Function New()
Return TechMethods.SomeTechFunction()
End Function
End Class
Public SomeClass
Public Function New()
Return Core.Tech.TechMethods.SomeTechFunction()
End Function
End Class
This is mostly a matter of style but the predominant pattern in .Net is to leverage
Importstatements. Not using anImportstatement causes unnecessary verbosity in your code. Especially when you consider the extremely long names of some .Net namespaces.For example
As I mentioned this is mostly a matter of style but there are some cases where it matters. Most importantly is the use of extension methods. The usefulness of this feature is severely limited if you don’t use any
Importstatements because it will restrict it to extension methods defined in the current namespace (goodbye LINQ).