我可以做一个类型"除了内部类型和QUOT密封; [英] Can I make a type "sealed except for internal types"

查看:177
本文介绍了我可以做一个类型"除了内部类型和QUOT密封;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使可以从通过类型相同的组件被继承一个类型,但不能从该组件的外继承。我想要的类型是装配的外部可见的。

I want to make a type that can be inherited from by types in the same assembly, but cannot be inherited from outside of the assembly. I do want the type to be visible outside of the assembly.

这可能吗?

推荐答案

您可以构造内部:

public class MyClass
{
    internal MyClass() { }
}

这从一个基类派生的每个类必须调用在其构造基类的构造函数。因为它不能调用构造函数,如果基类是在不同的装配,派生类不进行编译。

Every class that derives from a base class must call a constructor of the base class in its constructor. Since it can't call the constructor if the base class is in a different assembly, the derived class doesn't compile.

这篇关于我可以做一个类型"除了内部类型和QUOT密封;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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