Why is it impossible to use IList <T> in an interface definition and List <T> in an implementation?
Why is it impossible to use IList in an interface definition and then implement this property using List? Am I missing something here or is the C # compiler just not resolving this?
public interface ICategory
{
IList<Product> Products { get; }
}
public class Category : ICategory
{
public List<Product> Products { get { new List<Product>(); } }
}
the compiler says that error 82 'Category' does not implement the interface member 'i. category.Products'. "Category. Products" cannot implement "ICategory.Products" because it does not have the appropriate return type "System.Collections.Generic.IList"
+5
3 answers