[RESOLVED]Inconsistent accessibility: field type ' ' is less accessible than field ' '

I have MVC app but why do I get this type of error on the constructor?

Inconsistent accessibility: field type ‘WebsiteName.IDoctorRepository’ is less accessible than field ‘WebsiteName.HomeController._doctorRepo’

HomeController

namespace WebsiteName.Controllers
{
public class HomeController : Controller
{
public IDoctorRepository _doctorRepo;

public HomeController()
{
}

public HomeController(IDoctorRepository _doctorRepo) { //<<----ERROR HERE
this._doctorRepo = _doctorRepo;
}

public ActionResult Index()
{
return View();
}
}
}

IDoctorRepository

namespace WebsiteName.Repo
{
interface IDoctorRepository
{
int GetDoctorId(int docId);
}
}

DoctorRepository

namespace WebsiteName.Access
{
public class DoctorRepository : IDoctorRepository
{
public int GetDoctorId(int docId) {

return docId;
}
}
}

Thank You,

Try marking interface as public so that it will be avaialble for other layers (like controllers etc).

So change this from:

interface IDoctorRepository
{

to:

public interface IDoctorRepository
{
You need to add the key word public to your interface:

public interface IDoctorRepository

Leave a Reply