我创建了两个类Content和Bucket。 Bucket包含一组Content对象,并通过public属性公开。但是,当我这样做,我收到错误:
Property cannot be declared public because its type uses an internal type
对于为什么会引发错误的任何想法?
您还必须声明Content类的访问级别public。
public class Content { // some code }
如documentation所述:
A public variable cannot be defined as having an internal or private
type,because the type might not be available everywhere that the
public variable is used.
默认情况下,类被声明为内部,因此您必须添加public关键字才能使其公开。
函数也存在类似的规则。
A function cannot have a higher access level than its parameter types and return type,because the function could be used in situations where its constituent types are not available to the surrounding code.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。