我有一个接口将其他接口声明为属性
namespace Data.Repository
{
interface IUnitofWork : IDisposable
{
ICustomer Customer { get; }
int Complete();
}
}
我试图在UnitofWork类中实现此接口
namespace Data.Repository
{
public class UnitofWork : IUnitofWork
{
private readonly NORTHWNDEntities _context;
public UnitofWork(NORTHWNDEntities context)
{
_context = context;
customer = new CustomerRepository(_context);
}
public ICustomer customer { get; private set; }
public int Complete()
{
return _context.SaveChanges();
}
public void Dispose()
{
_context.Dispose();
}
}
}
但是它在编译时显示错误
错误:“ Data.Repository.UnitofWork”未实现接口成员“ Data.Repository.IUnitofWork.Customer”
请帮我解决这个错误
谢谢
最佳答案
区分大小写。在您的课堂上:
public ICustomer customer { get; private set; }
需要是
public ICustomer Customer { get; private set; }
(大写C,因为这就是您界面上的内容)
关于c# - 'Data.Repository.UnitofWork'未实现接口(interface)成员'Data.Repository.IUnitofWork.Customer',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35115043/