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 是本程序集其他程序集继承的子类可以访问。

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值