c# 是否有类似 'child' 命名空间的东西,或者像 Java 中的包范围?

Does c# have something like 'child' namespaces, or package scoping like in Java?

我不明白为什么在这种情况下不需要显式引用:

//SomeStaticClass.cs
namespace WhyDontINeedUsingStatement {

    public static class SomeStaticClass {
        public static string Thingy {
            get { return "Behold! A thingy!"; }
        }
    }

    public class SomeNonStaticClass {
        public void DoSomethingUseful() {
            var foo = 9; 
        }
    }
}

// /SomeNamespace/SomeBoringClass.cs
namespace WhyDontINeedUsingStatement.SomeNamespace {
    public class SomeBoringClass {
        public static void DoSomething() {
            var whatever = SomeStaticClass.Thingy;

            var blah = new SomeNonStaticClass();
            blah.DoSomethingUseful();            
        }
    }
}

为什么这不需要顶部的 using WhyDontINeedUsingStatement?这些不是独立的名称空间,即使它们以相同的东西开头吗?

我知道 C# 命名空间与 Java 包不太一样(并且不影响访问控制),但不知道为什么第二个 class 能够引用来自第一个.

根据 C# 语言规范版本 5.0,第 9.2 节,在命名空间声明中使用 . 似乎是语法糖:

The qualified-identifier of a namespace-declaration may be a single identifier or a sequence of identifiers separated by “.” tokens. The latter form permits a program to define a nested namespace without lexically nesting several namespace declarations. For example,

namespace N1.N2
{
    class A {}
    class B {}
}

is semantically equivalent to

namespace N1
{
    namespace N2
    {
        class A {}
        class B {}
    }
}

所以从 N2 内部你可以看到 N1,因此你可以使用它。