Okay, there's still a little bit of confusion here.
The inference that's going on has nothing to with the type of Object.SomeProperty, but everything to do with the types of the expressions in the array initializer. In other words, you could do:
object o = new[] { "string1", "string2" };
and o would still be a reference to a string array.
Basically, the compiler looks at an expression like this:
new[] { A, B, C, D, ... }
(where A, B, C, D etc are expressions) and tries to work out the correct array type to use. It only considers the types of A, B, C and D (etc) as the array element type. Taking this set of candidate types, it tries to find one which all the others can be implicitly converted to. If there's not exactly one such type then the compiler will complain.
So for example:
new[] { new Form(), new MemoryStream() }
will not compile - neither MemoryStream
nor Form
is convertible to the other. However:
new[] { GetSomeIDisposable(), new MemoryStream() }
will be treated as an IDisposable[]
because there's an implicit conversion from MemoryStream
to IDisposable
. Likewise:
new[] { 0, 1, 3.5 } // double[]
new[] { 1, 3, 100L } // long[]