c# - you cannot declare private, protected, protected internal directly in NS

785 ワード

namespace enumInXamldemo
{
    private class AClass
    {
        
    }
}

 with the simple class definiiton, is there any problem with it? 
 
yes, you cannot compile it, the C# compiler has made a step forward in making the some misleading access modifier invalid in some applications. 
 
so it does not make sense to make a private class inside a namespace root because 1. by default the class definition is private, and 2. namespace does not have access control, you cannot say this class is pirvate inside this namespace, it only provide a name management ability ,but it does not control how the accessiblity is, because the accessiblity is specificed on the assembly level..