命名空间内的私有类 [英] private classes inside namespaces

查看:41
本文介绍了命名空间内的私有类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
C#/.NET中仅命名空间的类可见性?

Possible Duplicate:
Namespace only class visibility in C#/.NET ?

我想要的是一个类,该类只能由同一名称空间内的其他类访问,而不必将名称空间放入其自己的程序集中.

What I want is to have a class that is only accessible to other classes inside the same namespace without having to put the namespace in it's own assembly.

是否有原因在C#中无法实现?

Is there a reason this is not possible in C#?

编辑:由于编译器告诉我不允许使用private,因此我对问题做了一些更改.有人可以告诉我原因吗?

Edit: I have change the question a little, since the compiler tells me that private is not allowed. Can anyone tell me the reason for this?

推荐答案

除了gehho的回答:名称空间只是类型名称的一部分(它仅允许所有类型具有唯一的名称)-这就是为什么您不能限制访问名称空间中的类型.

In addition to gehho's answer: namespace is just a part of the type name (which only allows for all types to have unique names) - that's why you cannot restrict access to types inside a namespace.

这篇关于命名空间内的私有类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆