Reputation: 107
i am using a MATLAB dll. it takes a matrix as type int[,] as input and the output is as type :object{double[,]}
private void pic_edges(int[,] array)
{
Class1 obj = new Class1();
object res = null;
res = obj.edge_dll(1, array, .5);
}
name ; value ; type
res ; {object[1]} ; object{object[]}
[0] ; {double[450,600]} ; object{double[,]}
now i want to change object{double[,]} to int[,] or double[,]. but how???
int[,] pic=null;
double[,] pic2=nu1l;
edit :
i used the following code :(thanks to 'now he who must not be named')
var objectArray = obj.edge_dll(1, array, .5);
double[,] pic3 = (double[,]) objectArray[0];
and it converts correctly.
Now how to convert double[,] to int [,]
i used this code : (But is there any better way??)
int[,] pic4 =new int[pic3.GetLength(0),pic3.GetLength(1)];
for (var i = 0; i < pic3.GetLength(0); i++)
for (var j = 0; j < pic3.GetLength(1); j++)
pic4[i, j] = (int)pic3[i, j];
Upvotes: 0
Views: 580
Reputation: 9396
You should type-cast
it.
If i understand your question correctly, you have something to convert from an object to integer array.
Try something like this:
var objectArray = obj.edge_dll(1, array, .5);
for (var index = 0; index <= objectArray.Count(); index++)
{
anIntegerArray[index] = (int) objectArray[index];
}
Upvotes: 1