title: IDictionary<TKey, TValue> in .NET 4 not covariant
body: <p>The <code>IDictionary&lt;TKey, TValue&gt;</code> in .NET 4 / Silverlight 4 does not support covariance, i.e. I can't do a</p>
  
  <pre><code>IDictionary&lt;string, object&gt; myDict = new Dictionary&lt;string, string&gt;();
  </code></pre>
  
  <p>analog to what I can do with <code>IEnumerable&lt;T&gt;</code>s now.</p>
  
  <p>Probably boils down to the <code>KeyValuePair&lt;TKey, TValue&gt;</code> not being covariant either. I feel that covariance should be allowed in dictionaries at least for the values.</p>
  
  <p>So is that a bug or a feature? Will it ever come, maybe in .NET 37.4?</p>
  
  <p>UPDATE (2 years later):</p>
  
  <p>There will be an <a href="http://msdn.microsoft.com/en-us/library/hh136548(v=VS.110).aspx" rel="noreferrer"><code>IReadOnlyDictionary&lt;TKey, TValue&gt;</code></a> in .NET 4.5, but it won't be covariant either <code>:·/</code>, because it derives from <code>IEnumerable&lt;KeyValuePair&lt;TKey, TValue&gt;&gt;</code>, and <code>KeyValuePair&lt;TKey, TValue&gt;</code> is not an interface and thus cannot be covariant.</p>
  
  <p>The BCL team would have to redesign a lot to come up and use some <code>ICovariantPair&lt;TKey, TValue&gt;</code> instead. Also strongly-typed indexers á la <code>this[TKey key]</code> aren't possible for covariant interfaces. A similar end can only be achieved by placing an extension method <code>GetValue&lt;&gt;(this IReadOnlyDictionary&lt;TKey, TValue&gt; self, TKey key)</code> somewhere which would somehow internally have to call an an actual implementation, which arguably looks like a quite messy approach.</p>