Hi,
Stefan's answer is correct, and if that completely solves your problem, then perfect. However, personally, I would consider to go one step further. The issue here is that List<T> is not covariant, which means this will not be possible:
List<Person> personList = UserProfileGatherer.Collect(...);
If you want to make that possible, and the returned list is read only, then could make use of IReadOnlyList which is covariant, e.g.
public interface IResourceGatherer<T> where T : IResource
{
public IReadOnlyList<T> Collect(string id);
}
As List<T> implements IReadOnlyList<T>, your implementations would not need to change.
Regards,
Nick.
No comments:
Post a Comment