Hi,
I have to create a bi-dimensional matrix, where each row is a int [] array of a specific size. For adding a new row, I use the ArrayList.Add (int []) command.
I would like now to convert this ArrayList object, to a int[,] variable. I only managed to do it with a double "for loop" for reading each row and column.
Considering we have N rows and M columns, I have tried first trying to copy each single row:
int arr = new int[N,M];
((int[])arrayList[i]).CopyTo(arr,i*M*sizeof(int)); //repeated for each i=0; i<N
this crashes, i think coze CopyTo is only allowed between one-dimensional arrays.
I tried then this thing:
int [,] arr = (int[,])arrayList.ToArray(typeof(int[]));
but it also crashes. Any idea of how do it in a more efficient way as with two "for -loops"?
thank you very much