【问题标题】:Inconsistent accessibility: parameter type 'ICourseRepository' is less accessible than method ASP.NET Core MVC [closed]可访问性不一致:参数类型“ICourseRepository”比方法 ASP.NET Core MVC 更难访问 [关闭]
【发布时间】:2021-07-12 01:46:17
【问题描述】:

我在控制器构造函数中收到此错误

可访问性不一致:参数类型“IContactRepository”的可访问性低于方法“ContactController.ContactController(IContactRepository)”

【问题讨论】:

标签: c# visual-studio asp.net-core asp.net-core-mvc asp.net-core-3.1


【解决方案1】:

您必须在定义的文件中将IContactRepository 设置为public

public interface IContactRepository {
  ...
}

【讨论】:

    【解决方案2】:

    已解决:

    我从这里改变了界面

    Interface ICourseRepository{
            Contact GetContact(int id);
            IEnumerable<Contact> GetAllContact();
            Contact Add(Contact contact);
            Contact Delete(int id);
    }
    

    到这里

    Public Interface ICourseRepostory{
            Contact GetContact(int id);
            IEnumerable<Contact> GetAllContact();
            Contact Add(Contact contact);
            Contact Delete(int id);
    }
    

    【讨论】:

    • 是的,正如我回答的那样,
    猜你喜欢
    • 2011-09-07
    • 2014-10-31
    • 1970-01-01
    • 1970-01-01
    • 2019-05-14
    • 2019-01-12
    • 1970-01-01
    相关资源
    最近更新 更多