I have an o开发者_开发技巧bject array that has 8 entries in it from value 0 to 7. All of the values are pretty standard, but the value in the [7, 0] spot is a string and for [7, 1] it is another object with two entries, [0, 0] and [0, 1].
My question is, I am trying to assign the object in the [7, 1] spot to a separate object array and then am pulling the [0, 1] string value from that object. My syntax for assigning the 7th spot array to another array keeps coming up null though. What is the correct syntax for either A) Assigning that object to a usable object B) Or just flat out pulling the value from the [7, 1] array and the [0, 1] inner object to a string?
I am using this right now: object[,] checkCD = param[7, 1] as object[,];
which is coming up null, I would rather just get the string from the inner object flat out but help!
For what I could understand of your question, if after executing this line
object[,] checkCD = param[7, 1] as object[,];
checkCD
is null, then it means that param[7, 1]
does not contain an object[,]
, but something of another type (or null).
Try instead
object x = param[7, 1];
and check what's the type of x
- maybe you just put in [7,1] the wrong thing. If after this, x is null then it means that param[7, 1]
is really null.
This works for me, am i missing anyting.
object[,] array1 = new object[8,2];
array1[7,1] = new object[1,2] { {"00","01"}};
array1[7,0] = new StringBuilder("Initialized");
object[,] seventthobj = (object[,])array1[7, 1];
Assignment should be param[7,1] = new object[,] {{value, "string"}};
.
精彩评论