`

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

    博客分类:
  • C#
c# 
阅读更多
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..

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics