Question import namespace in each form or globally?

teddy.frm

Member
Joined
Jan 3, 2014
Messages
5
Programming Experience
3-5
Hello all, i'm using vb .net to develop inventory control software.
There're MDI Parent form and several MDI Children forms.
Most forms import namespace System.Data.SqlClient
Which is better, import System.Data.SqlClient to each form or just add it to reference ?
Thanks
 
It doesn't really matter. The compiled code will be same because importing namespaces is just a convenience when you're writing code. If you have a tool that will add the import for you automatically, e.g. ReSharper, then it's possibly easier to just add it to each code file as you need it. Otherwise, if you know that you're going to be importing the same namespace a lot, it's easier to do it once at the project level, which only takes checking a box rather than writing any code.

There is one case where it's a genuine advantage to import at the file level rather than the project, and that's where you want to use the same type name from different namespaces in different files.
 
Back
Top