S
Sankar Nemani
Why does the following code throw an exception?
object[] o = new object[2]{"sankar", "sankar2"};
string[] s;
s =(string[])o;
The C# language spec says something different on MSDN:
For any two reference-types A and B, if an implicit reference conversion
(Section 6.1.4) or explicit reference conversion (Section 6.2.3) exists from
A to B, then the same reference conversion also exists from the array type
A[R] to the array type B[R], where R is any given rank-specifier (but the
same for both array types).
object[] o = new object[2]{"sankar", "sankar2"};
string[] s;
s =(string[])o;
The C# language spec says something different on MSDN:
For any two reference-types A and B, if an implicit reference conversion
(Section 6.1.4) or explicit reference conversion (Section 6.2.3) exists from
A to B, then the same reference conversion also exists from the array type
A[R] to the array type B[R], where R is any given rank-specifier (but the
same for both array types).