This, of course, is not a good practice. This makes a few examples simpler, like "hello world" - perhaps C # designers were going for code golf, p
But yes, this is weird. I do not know of any high-profile reason why we need to be able to directly use the global namespace. Even for extension methods, I would rather add a using directive to bring them to ...
Interestingly, in mscorlib.dll are apparently 40 such odd and 20 odd in system.dll
var mscorlib = typeof(string).Assembly.GetTypes() .Where(t => string.IsNullOrEmpty(t.Namespace)).ToList(); var system = typeof(Uri).Assembly.GetTypes() .Where(t => string.IsNullOrEmpty(t.Namespace)).ToList();
(but all private / compilers)
Marc gravell
source share