title: Why is array co-variance considered so horrible?
body: <p>In .NET reference type arrays are co-variant. This is considered a mistake. However, I don't see why this is so bad consider the following code:</p>
  
  <pre><code>string[] strings = new []{"Hey there"};
  object[] objects = strings;
  objects[0] = new object();
  </code></pre>
  
  <p>Oh ho, this compiles and will fail at runtime. As we tried to stick an object into a string[]. Okay, I agree that stinks, but a T[] extends Array and also implements <code>IList</code> (and <code>IList&lt;T&gt;</code>, I wonder if it implements <code>IList&lt;BaseType&gt;</code>...>. Both Array and IList allow us to make the same horrid mistake.</p>
  
  <pre><code>string[] strings = new []{"Hey there"};
  Array objects = strings;
  objects.SetValue(new object(),new[]{0});
  </code></pre>
  
  <p>IList version</p>
  
  <pre><code>string[] strings = new []{"Hey there"};
  IList objects = strings;
  objects[0] = new object();
  </code></pre>
  
  <p>The T[] classes are generated by the CLR, and have to include a type check on the equivalent of the <code>set_Item</code> method (arrays don't actually have one). </p>
  
  <p>Is the concern that setting to a T[] has to do the type check at runtime (which violates the type-safety you expect at compile time)? Why is it considered harmful for arrays to exhibit this property when there are equivalent means to shoot yourself in the foot through the provided means above? </p>