为什么内部保护并不比内部更严格? [英] Why is internal protected not more restrictive than internal?

查看:141
本文介绍了为什么内部保护并不比内部更严格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个内部的自动属性:

I'd like to create an internal auto-property:

internal bool IP { get; protected internal set; }



我认为这将有可能使二传手保护受保护的内部 - 但我总是得到错误的访问性修饰符必须比属性<更严格/ STRONG>。是不是这样的? 私人并不能帮助我,在这里

I thought it would be possible to make the setter protected or protected internal - but I always get the error accessibility modifier must be more restrictive than the property. Isn't that the case? Private does not help me, here.

编辑:

中的问题是:我如何实现一个自动属性与内部getter和一个受保护的setter


The question is: How do I implement an auto-property with a internal getter and a protected setter?

推荐答案

这是有效地保护内部,而不是。这是访问的两个按同一程序集中派生类和类型。这是一个普遍的误解,认为受保护的内部表示只访问同一程序派生类。

It's effectively protected or internal, not and. It's accessible both by derived classes and types in the same assembly. It's a common misconception to think protected internal means accessible only to derived classes in the same assembly.

这篇关于为什么内部保护并不比内部更严格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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