I\'m new to interfaces and abstract classes. I want to create a couple of interfaces to define core methods and variables for the objects for a shopping cart system. Then I want
This is a matter of contra/covariance.
2 changes are required to make this compile.
1) Remove the "set" option on the property of the interface. (It's only implementing a get; property, which makes the most sense, in any case)
2) Change Cart to:
public abstract class Cart : ICart
{
private List _cartItems = new List();
public List CartItems
{ ...
I also highly recommend changing your interface to expose IList instead of List. The design guidelines (and FxCop) recommend not exposing List in the public interface. List is an implementation detail - IList is the appropriate interface/return type.