【发布时间】:2013-03-20 19:57:46
【问题描述】:
我有以下:
public class TestService : BaseService, IDisposable
{
public TestService(IRepositoryProvider repositoryProvider)
{
}
public IRepository<Exam> Exams { get { return GetStandardRepo<Exam>(); } }
}
和
public class BaseService : IDisposable
{
public BaseService(IRepositoryProvider repositoryProvider)
{
CreateDbContext();
repositoryProvider.DbContext = DbContext;
RepositoryProvider = repositoryProvider;
}
}
有人能告诉我为什么第一个类有错误说“基础服务不采用零参数的构造函数”吗?
【问题讨论】:
-
因为
BaseService没有零参数的构造函数。它只有一个参数。 -
默认情况下,编译器只能调用基类的无参数构造函数,否则您必须手动添加该调用
标签: c#