【发布时间】:2017-08-05 11:50:49
【问题描述】:
我有一个interface
interface Repository {
...
List<T> GetAll<T>();
...
}
我应该如何实现该方法?编译器说我不能像下面显示的那样做,因为我返回的不是通用列表
public class EmployeeRepository : Repository {
...
public List<T> GetAll<T>() {
List<Employee> employees = new List<Employee>();
...
return employees;
}
【问题讨论】:
-
方法的签名意味着你可以调用例如
repository.GetAll<User>()。你想怎么处理?
标签: c# .net inheritance interface