I have the following code which I am trying to debug
int ll(ref float[,] _lv) {
object[] results = new object[20];
results = func_v1(11, _lv);
}
Breaking to watch variable 'results' shows something like below
results {object[11]}
+ [0] {float[1,1]}
+ [1] {double[1,1]}
+ [2] {float[48,1]}
...
...
+ [10] {float[1,1]}
and I am not able to type cast to get values from it
float f = (float)results[0];
throws an invalid cast exception.
Please help me understand what exactly is this object array and how I can get values out of it.
regards. ak
You're using a multidimensional array which you can read about here: http://msdn.microsoft.com/en-us/library/2yd9wwz4(v=vs.71).aspx
You need to cast it appropriately
var f = (float[,])results[0]
The item at index 0 is not a float
- it's a float[,]
.
float f = (float)results[0];
throws an invalid cast exception.
I think you need
float[,] f = (float[,])results[0];
double[,] d = (double[,])results[1];
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