0
public class Employee : IEmployee
{
    private String name;
    private String department;
    private int salary;
    private List<IEmployee> subordinates;

    public void addEmployee(String name, String department, int salary)
    {
        this.name = name;
        this.department = department;
        this.salary = salary;
    }

    public void addSubordinate(IEmployee e)
    {
        subordinates.add(e);
    }

interface IEmployee
{
    void addEmployee(String name, String department, int salary);
    String getEmployeeInfo();
    void addSubordinate(IEmployee e);
}

public void If_We_Add_Alan_As_Johns_Subordinate_We_SHould_get_that()
{
        ObjectFactory.Configure(x =>
        {
            x.For<IEmployee>().Use<Employee>();
        });
        var DairyManager = ObjectFactory.GetInstance<IEmployee>();
        var Cashier = ObjectFactory.GetInstance<IEmployee>();

        Cashier.addEmployee("Alan", "cashier", 1000);
        DairyManager.addEmployee("John", "CEO", 10000);
        DairyManager.addSubordinate(Cashier); 

The error says :

Inconsistent accessibility: parameter type IEmployee is less accessible than method Employee.addSubordinate(Supermarket.IEmployee)...

steveax
  • 17,527
  • 6
  • 44
  • 59

3 Answers3

4

You have not provided an access modifier for your interface:

interface IEmployee

Therefore, the default (implied) access modifier is internal. Just add public, like this:

public interface IEmployee
rory.ap
  • 34,009
  • 10
  • 83
  • 174
2

You should mark the interface as public.

public interface IEmployee

Since the access modifier of Employee is public the same should hold for the interfaces that Employee implements.

Christos
  • 53,228
  • 8
  • 76
  • 108
1

You just need to add an accessibity modifier to your interface:

public interface IEmployee

This will fix the error.

Fenton
  • 241,084
  • 71
  • 387
  • 401