title: c# list of interface with generic items
body: <p>My question is somewhat similar to 
  <a href="https://stackoverflow.com/questions/4522580/generic-list-of-generic-interfaces-not-allowed-any-alternative-approaches">Generic List of Generic Interfaces not allowed, any alternative approaches?</a></p>
  
  <p>If I have an interface such as</p>
  
  <pre><code>public interface IPrimitive
  {
  
  }
  
  public interface IPrimitive&lt;T&gt; : IPrimitive
  {
       T Value { get; }
  }
  
  public class Star : IPrimitive&lt;string&gt; //must declare T here
  {
      public string Value { get { return "foobar"; } }
  }
  
  public class Sun : IPrimitive&lt;int&gt;
  {
      public int Value { get { return 0; } }
  }
  </code></pre>
  
  <p>Then I have a list</p>
  
  <pre><code>var myList = new List&lt;IPrimitive&gt;();
  myList.Add(new Star());
  myList.Add(new Sun());
  </code></pre>
  
  <p>When looping through this list, how do I get the Value property?</p>
  
  <pre><code>foreach (var item in myList)
  {
      var value = item.Value; // Value is not defined in IPrimitive so it doesn't know what it is
  }
  </code></pre>
  
  <p>I'm not sure how this is possible.</p>
  
  <p>Thanks,
  Rob</p>