我正在尝试使用Aforge.Math来做这件事,我想要一个列表,然后在一个复杂的列表中...例如,清单1,2中有一个包含5个数字的复杂列表,对于其他位置也是如此:
List<int>[,] Alist = new List<int>[20,20];
AForge.Math.Complex[] input = new AForge.Math.Complex[5];
for(int a=1; a<=5; a++){
for(int b=1; b<=20; b++){
for(int c=1; c<=20; c++){ //all 'for's must be in this order
input[a].Re = a * b; //for example
input[a].I = 0.0;
Alist[b,c] = input; //ERROR
}
}
}错误:Cannot implicity convert type 'AForge.Math.Complex[] to 'System.Collections.Generic.List<int>'
如果我使用Array而不是List,会给出同样的错误。我该怎么做呢?有什么想法吗?
谢谢!
发布于 2014-03-15 01:09:31
对你的代码进行注释;
List<int>[,] Alist = new List<int>[20,20]; AForge.Math.Complex[] input = new AForge.Math.Complex[5];// OK,输入是AForge.Math.Complex的一维数组
for(int a=1; a<=5; a++){
for(int b=1; b<=20; b++){
for(int c=1; c<=20; c++){ //all 'for's must be in this order
input[a].Re = a * b; //for example
input[a].I = 0.0;
Alist[b,c] = input; //ERROR//嗯。List的每个成员都必须是一个列表,正如你所说的,它是一个列表的二维数组。因此,将成员b、c设置为AForge.Math.Complex的一维数组是错误的
}
}
}我真的不确定你想做什么,但我希望你能理解现在什么不起作用。
https://stackoverflow.com/questions/22410860
复制相似问题