The problem is that you cannot initialize the internal array this way. An array initializer can only be used in a variable or field initializer. As stated in your error:
An array initializer can only be used in a variable or field initializer. Try using the new insead expression
You must explicitly initialize nested arrays. Do it like this and it works:
object[] x = { 1, "G", 2.3, 2, 'H', new int[]{ 2 } };
Read more about Array Initializers
Your syntax will work if you define a two-dimensional array:
object[,] x = { {"3"}, { 1 }, { 2 } };
source share