• C#的protected internal


    关于C#的protected internal,也许你在网上可以找到两种解释:


    第一种解释是,protected or internal ,即在本程序集或其他程序集继承的子类可以访问。

    第二种解释是,protected and internal,即在本类或本程序集继承的子类可以访问。



    这需要判断protected  internal 是何种解释,就要从微软的MSDN中得到答案。


    摘要原文:

    protected internal


    The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.


    译文:

    该类型或成员可以在声明的程序集的程序集中的任何代码或在另一个程序集内的派生类中访问。从另一个程序集的访问必须发生在一个类声明中,该类声明中声明受保护的内部元素的类,它必须通过派生类类型的实例发生。



    微软开发者:


    protected internal


    由其声明的程序集或另一个程序集派生的类中任何代码都可访问的类型或成员。 从另一个程序集进行访问必须在类声明中发生,该类声明派生自其中声明受保护的内部元素的类,并且必须通过派生的类类型的实例发生。


    所以,protected  internal 是本程序集其他程序集继承的子类可以访问。

  • 相关阅读:
    练习2-15 求简单交错序列前N项和(15 分)
    js预解析实例
    one:arguments对象伪数组
    第一章 评估工具
    第6章条件处理
    第五章----过程
    第4章 数据传递.寻址和算术运算
    第3章 汇编语言基础
    第2章-------------IA-32处理器体系结构
    第一章-------基本概念
  • 原文地址:https://www.cnblogs.com/maokun/p/6710815.html
Copyright © 2020-2023  润新知