内部方法和数据结构。
如果我有一个受保护的方法,我可以传入一个数据类型声明为内部的参数吗?
if i have a protected method, can i pass in a parameter where the data type is declared internal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不可以,除非类型(带有受保护成员)本身就是内部的。 内部类型不能成为公共/受保护 API 的一部分,因为消费者无法使用它。
但是,您可以考虑使用公共接口来抽象类型 - 即
泛型对此也很有用:
No, unless the type (with the protected member) is itself internal. Internal types cannot be part of a public/protected API, as the consumer would have no way of using it.
You could, however, consider using a public interface to abstract the type - i.e.
Generics can be useful for this too:
如果包含受保护方法的类是外部可见的,则不会。 这是因为某些外部类可以从该类派生,并且需要知道参数的类型。
Not if the class that contains the protected method is externally visible. That's because some external class could derive from that class and would need to know the type of the parameter.