PenguinBlast PenguinBlast - 28 days ago 23
C# Question

Inconsistent Accessibility in Lists c#

I'm following an RPG c# tutorial, and have come across this error. It is not explained in the tutorial, and I'm unsure what i did wrong.

Here is the class:

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>();

}
}
}


The problem lies in:
public List<LootItem> LootTable { get; set; }


I get the error message: "Inconsistent accessibility: property type 'List' is less accessible than property 'Monster.LootTable'"

I also get the same error message in another class, but if I can fix this one, i can hopefully fix the other.

Answer

Make the LootItem class public,

public class LootItem
    {

    }
}
Comments