1

I'm trying to create an object of RecipeManager in mainForm but I get this error:

Inconsistent accessibility: base class 'Assign_1.ListManager<Assign_1.Recipe>' is less accessible than class 'Assign_1.Managers.RecipeManager'

RecipeManager:

public class RecipeManager : ListManager<Recipe>
    {
        public RecipeManager()
        {

        }
    }

ListManager:

 public class ListManager<T> : IListManager<T>
    {
        protected List<T> m_list;

        public ListManager()
        {
            m_list = new List<T>();
        }

        public int Count
        {
            get { return m_list.Count; }
        }

I have another manager class that works fine:

public class AnimalManager : ListManager<Animal>
{
    private int startID =100;

    public AnimalManager()
    {
    }

I have all Manager classes in a folder called Managers

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Kevin.A
  • 77
  • 2
  • 11

1 Answers1

10

Generic class is as accessible as least accessible of all parameter. So most likely Recipe class is not public.

Fix: make sure to declare Recipe as public explicitly.

Note that omitting accessibility is most likely reason of class not being public - check out What are the Default Access Modifiers in C#? for defaults.

class Recipe { ... {

means

internal class Recipe {....}
Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179