Pregunta

I tried

public class Chest(Item):
    public contents as Item

But that's of course a single Item, not a list. How do I declare contents as a list of items?

¿Fue útil?

Solución

You can use generics, like this:

import System.Collections.Generic

class Chest(Item):
  contents as List[of Item]

PS you shouldn't expose fields as public on classes. Create a property instead.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top