我有一个像
这样的界面interface IEmpDeptRepository : IEmployeeRepository,IDepartmentRepository
{
IEnumerable<EmpDept> GetAll();
}
interface IEmployeeRepository
{
IEnumerable<Employee> GetAll();
}
interface IDepartmentRepository
{
IEnumerable<Department> GetAll();
}
Class EmpDept 是
class EmpDept
{
public List<Employee> Employees { get; set; }
public List<Department> Departments { get; set; }
}
现在, EmpDeptRepository 类位于
之下 public class EmpDeptRepository:IEmpDeptRepository
{
private List<EmpDept> empDepts = new List<EmpDept>();
public EmpDeptRepository()
{
Add(new EmpDept { Employees = IEmployeeRepository.GetAll(), Departments = IDepartmentRepository.GetAll() });
}
public EmpDept Add(EmpDept empDept)
{
if (empDept == null)
{
throw new ArgumentNullException("Employee Department");
}
empDepts.Add(empDept);
return empDept;
}
public IEnumerable<EmpDept> GetAll()
{
return empDepts;
}
IEnumerable<Employee> IEmployeeRepository.GetAll()
{
IEmployeeRepository employeeRepository = new EmployeeRepository();
return employeeRepository.GetAll();
}
IEnumerable<Department> IDepartmentRepository.GetAll()
{
IDepartmentRepository deptRepository = new DepartmentRepository();
return deptRepository.GetAll();
}
}
我收到以下错误
Error 1 Inconsistent accessibility: parameter type 'Models.EmpDept' is less accessible than method 'Models.EmpDeptRepository.Add(Models.EmpDept)'
Error 2 Inconsistent accessibility: return type 'Models.EmpDept' is less accessible than method 'Models.EmpDeptRepository.Add(Models.EmpDept)'
Error 3 Inconsistent accessibility: return type 'System.Collections.Generic.IEnumerable<Models.EmpDept>' is less accessible than method 'Models.EmpDeptRepository.GetAll()'
错误是什么..请帮助?
答案 0 :(得分:1)
公开所有课程:
public class EmpDept
答案 1 :(得分:1)
将类EmpDept设为公开,因为当您想使用公共方法访问它时,它也必须是公共的。