Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试过
public class Chest(Item): public contents as Item
但这当然是单个项目,而不是列表。如何申报contents为物品清单?
contents
您可以使用泛型,如下所示:
import System.Collections.Generic class Chest(Item): contents as List[of Item]
PS你不应该在类上公开字段。而是创建一个属性。