I come across the codes below:
public class Basket
{
public Guid BasketId { get; set; }
public DateTime Date { get; set; }
public virtual ICollection<BasketItem> BasketItems { get; set; }
public Basket()
{
BasketItems = new List<BasketItem>();
}
}
The part I do not quite understand is that why would we put
public virtual ICollection<BasketItem> BasketItems { get; set; }
instead of
public virtual List<BasketItem> BasketItems { get; set; }
One reason I can think of is that when this class is inherited, we can override BasketItems with different types?
What are other reasons of doing so?