我知道这不能编译,但为什么不应该呢?返回列表中的具体实现
public interface IReportService {
IList<IReport> GetAvailableReports();
IReport GetReport(int id);
}
public class ReportService : IReportService {
IList<IReport> GetAvailableReports() {
return new List<ConcreteReport>(); // This doesnt work
}
IReport GetReport(int id){
return new ConcreteReport(); // But this works
}
}
。 – jgauffin