列表中不一致的可访问性

本文关键字:访问 不一致 列表 | 更新日期: 2023-09-27 18:16:35

我遵循RPG c#教程,并遇到了这个错误。在教程中没有解释,我不确定我做错了什么。

下面是类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Engine
{
    public class Monster : LivingCreature
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public int MaximumDamage { get; set; }
        public int RewardExperiencePoints { get; set; }
        public int RewardGold { get; set; }
        
        public List<LootItem> LootTable { get; set; }
        public Monster(int id, string name, int maximumDamage, int rewardExperiencePoints, int rewardGold, int currentHitPoints, int maximumHitPoints) : base (currentHitPoints, maximumHitPoints)
        {
            ID = id;
            Name = name;
            MaximumDamage = maximumDamage;
            RewardExperiencePoints = rewardExperiencePoints;
            RewardGold = rewardGold;
            LootTable = new List<LootItem>();
                
        }
    }
}

问题在于:public List<LootItem> LootTable { get; set; }

我得到错误信息:"不一致的可访问性:属性类型'List'比属性'Monster.LootTable'"

我在另一个类中也得到相同的错误信息,但如果我能修复这个,我希望能修复另一个

列表中不一致的可访问性

将lotitem类设为public,

public class LootItem
    {
    }
}