G
GB
Hello:
I have ArrayList strat_list of integers like this:
index value
[0] 3
[1] 4
[2] 2
[3] 1
[4] 6
[5] 4
[6] 3
[7] 2
[8] 5
[9] 8
[10] 6
[11] 2
I want to put the content of the list in 2 dimensional array to get a
matrix like this:
3421
6432
5862
This is what I am doing:
int k = 4;
int[,] myArr = new int[strat_list.Count,k];
myArr = (int[,])strat_list.ToArray(typeof(int[,]));
But it gives me InvalidCastException error.
Could you give me a hint how to fix the problem?
Thanks,
GB
I have ArrayList strat_list of integers like this:
index value
[0] 3
[1] 4
[2] 2
[3] 1
[4] 6
[5] 4
[6] 3
[7] 2
[8] 5
[9] 8
[10] 6
[11] 2
I want to put the content of the list in 2 dimensional array to get a
matrix like this:
3421
6432
5862
This is what I am doing:
int k = 4;
int[,] myArr = new int[strat_list.Count,k];
myArr = (int[,])strat_list.ToArray(typeof(int[,]));
But it gives me InvalidCastException error.
Could you give me a hint how to fix the problem?
Thanks,
GB