一道练习题,最后那边不知道该怎么做了,希望各位能指点一下啊

img
主要不知道加装物品那一步数组该如何写,在 Hero结构体中设tem[]字段那么构造的时候怎么把item这个类数组中的值给赋进去呢。

参考,有帮助麻烦点个采纳【本回答右上角】,谢谢~~
img


using System;
using System.Linq;
namespace ConsoleApplication1
{
    public enum ItemType
    {
        消耗品,
        装备,
        武器,
        材料
    }
    class Item
    {
        public string Name { get; set; }
        public double BuyPrice { get; set; }
        public double SalePrice { get; set; }
        public ItemType Type { get; set; }
        public Item(string Name, double BuyPrice, double SalePrice, ItemType Type)
        {
            this.Name = Name;
            this.BuyPrice = BuyPrice;
            this.SalePrice = SalePrice;
            this.Type = Type;
        }
    }
    enum HeroType
    {
        法师,
        战士,
        刺客,
        坦克,
        射手,
        辅助
    }
    class Hero
    {
        public string Name { get; set; }
        public Item[] items { get; set; }

        public HeroType Type { get; set; }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var hero = new Hero { Name = "凹凸曼", Type = HeroType.战士 };
            hero.items = new Item[] {
            new Item("消耗品1",100,120, ItemType.消耗品),
            new Item("材料1",100,120, ItemType.材料),
            new Item("武器1",100,120, ItemType.武器),
            new Item("装备1",100,120, ItemType.装备)
            };

            Console.WriteLine(hero.Name + "," + hero.Type);
            Console.WriteLine("物品");
            Console.WriteLine(string.Join("\n", hero.items.Select(i => i.Name + "," + i.BuyPrice + "," + i.SalePrice + "," + i.Type).ToList()));
            Console.ReadKey();
        }
    }
}

public struct Hero
    {
        public Item[] items; 
        public string name;
        public Hero(int n, string Name)  
        {
            name = Name;
            items= new Item[n];
        }
  }