C#内部访问修饰符 [英] C# internal access modifiers

查看:122
本文介绍了C#内部访问修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个命名空间,以密封类。我一直在寻找的内部访问修饰符,但这似乎只在装配密封类。我可以在一个命名空间密封类?

I want to seal of classes in a namespace. I was looking at the "internal" access modifier, but this only seems to seal of classes in an assembly. Can I seal of classes in a namespace?

还是我要的东西进入一个单独的组件?但后来我将有视觉工作室拒绝圆形集引用的问题。

Or do I have to move stuff into an seperate assembly? But then I will have the problem of visual studio refusing circular assembly references.

推荐答案

没有,有没有具体的名称空间修饰。一种选择是使用继承和一个protected的,但有一个内部构造函数的基类,这样外部的代码不能继承它。这可能帮助。

No, there is no namespace-specific modifier. One option would be to use inheritance and a "protected" modifier, but having an internal constructor on the base-class so that external code can't subclass it. That might help.

这篇关于C#内部访问修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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