edit typos
Hi,
This is possibly a moronic question, but if it helps me follow best practice I don’t care 😛
Say I want to use classes & methods within the System.Data namespace… and also the System.Data.SqlClient namespace.
Is it better to pull both into play or just the parent, ie…
using System.Data
using System.Data.SqlClient
or just…
using System.Data
More importantly I guess, does it have ANY effect on the application – or is it just a matter of preference (declaring both the parent and child keeps the rest of the code neat and tidy, but is that at the detriment of the application’s speed because its pulling in the whole parent namespace AND then a child?)
Hope thats not too much waffle
It doesn’t make any difference to the compiled code.
Personally I like to only have the ones that I’m using (no pun intended) but if you want to have 100 of them, it may slow down the compiler a smidge, but it won’t change the compiled code (assuming there are no naming collisions, of course).
It’s just a compile-time way of letting you write Z when you’re talking about X.Y.Z… the compiler works out what you mean, and after that it’s identical.
If you’re going to use types from two different namespaces (and the hierarchy is largely illusional here) I would have both
usingdirectives, personally.