Arrays are covariant, but a System.Int32[] does not contain references to things that are obtained from System.Object . In the .NET runtime, each value type definition actually defines two types of things: the type of the heap object and the type of the value (storage type). The type of heap object obtained from System.Object ; the type of storage location is implicitly converted to the type of the heap object (which, in turn, comes from System.Object ), but by itself is not inferred from System.Object and nothing else. Although all arrays, including System.Int32[] , are heap object types, the individual System.Int32[] elements are instances of the storage location type.
The reason a String[] can be passed to code waiting for Object[] is because the former contains "references to instances of a heap type object obtained from the String type," and the latter is similar for the Object type. Since String comes from Object , a reference to a heap object of the type derived from String will also be a reference to a heap object that comes from Object , and a String[] will contain references to heaps of objects that derive from Object - exactly what expect code from Object[] . On the contrary, since a int[] [ie System.Int32[] ] does not contain references to heap instances of type Int32 ; its contents will not meet the expectations of the code that Object[] expects.
source share