title: How do I define the return type of an interface method to be another interface?
body: <p>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 to create abstract classes which implement the core functions. The idea is that they can be used by other classes in slightly different ways for different projects.</p>
  
  <p>Here are my (cut-down) interfaces:</p>
  
  <pre><code>public interface ICart
  {
      ...
      List&lt;ICartItem&gt; CartItems { get; set; }
  }
  
  public interface ICartItem
  {
      int ProductId { get; set; }
      int Quantity { get; set; }
  }
  </code></pre>
  
  <p>And here is my abstract Cart class (again, only showing relevant lines) which implements ICart:</p>
  
  <pre><code>public abstract class Cart : ICart
  {
  
      private List&lt;CartItem&gt; _cartItems = new List&lt;CartItem&gt;();
  
      public List&lt;CartItem&gt; CartItems 
      {
          get
          {
              return _cartItems;
          }
      }
  }
  </code></pre>
  
  <p>And my CartItem class which implements ICartItem:</p>
  
  <pre><code>public abstract class CartItem : ICartItem
  {
      ...
  }
  </code></pre>
  
  <p>When I try to compile the classes I get an error saying: 'Cart' does not implement interface member 'CartItems'. 'Cart.CartItems' cannot implement 'ICart.CartItems' because it does not have the matching return type of System.Collections.Generic.List&lt;ICartItem&gt;.</p>
  
  <p>I thought that the idea here is that the interface can be implemented by a number of classes which perform the core functions in different ways and add new methods, etc. Why would my interface need to know what class is actually being used, just as long as that class actually implements the interface correctly? </p>