consider the variable ob4 as shown in figure
now : how can i reach ob4[0]->[0,2]
var o=ob4[0];
double[,] p=(double[,]) o[0,0];
the line (double[,] p=(double[,]) o[0,0];) gives the following error :
Cannot apply indexing with [] to an expression of type 'object'
You need to cast o[0, 0]
to object[,]
first:
var o = (object[,]) ob4[0];
double[,] p = (double[,]) o[0, 0];
It would be better if you could avoid having all these nested multi-dimensional arrays with so little type information at compile-time though - you haven't given us much context, but if you could change your object model, it would help a lot.
Well, from the error message it is obvious that the runtime thinks o
is object
, not object[,]
. So you might want to change your code to:
double[,] = (double[,])((object[,])o)[0,0];
Now the runtime knows that o
should be treated as object[,]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With