3 ms·
maybe Im misunderstanding you here, but when you have a collision of namespaces like that cant you just fully qualify the object you want? eg var foo = new Nam
by S_A_P 16y ago
maybe Im misunderstanding you here, but when you have a collision of namespaces like that cant you just fully qualify the object you want?
eg var foo = new Name.Space.Object();
For me the using statement in C# is handy shorthand for something that implements IDisposable(say, SqlClient for example) making sure that Dispose gets called.
- sukuriant 16y agoThe using statement the flietz is referring to goes at the beginning of the program, generally, next to all of the other "usings". It's mostly useful when you don't want to type out the fully qualified name of a class just to use an object of it. It's a code brevity feature.
- Groxx 16y agoNo, though say you have three nested namespaces for your utility class, and many other classes in those namespaces at varying levels and another version by the same name exists in global scope. There's even another version of the same class that's deprecated, but used in one or two places, and sites mid-way through the namespacing. And ASP is so #^@%in brilliant, everything resides in a single app_code folder and non-namespaced classes cannot be not-imported (as far as I've been able to tell). You can name.space.the.object, absolutely. Though it's closer to TheMasterNameSpace.Utilities.DatabaseConnectivity.TheClassNameThatIsUnnecessarilyLong, and that would have to be typed every time you wish it to be used. That amounts to literally hundreds of times that must be typed in some of the larger chunks of code, and tens of thousands if not significantly more over the course of a decent sized project. Changing this to "using TC = ..." makes it immensely less of a PITA, and changing it to use a different version (with the same API) requires changing a single location. And I am fully, painfully, daily aware of how bad this architecture is, there's no need to point this out. I'm part of the process of correcting this injustice.