我正在尝试创建一个返回数组列表中所有值的总和的方法。我在这一行上得到一个错误,sum+= setItem[x][y][z];错误是
expression must have pointer-to-object or handle-to-CLI-array type c:\Development\Source\Source\Source.cpp全功能
int getTotal(ArrayList^ set)
{
int sum = 0;
for each (Array^ setItem in set)
{
for(int x = 0; x< 3; x++)
{
for(int y = 0; y < setItem->Length; y++){
for(int z = 0; z< setItem->Length; z++)
{
sum+= setItem[x][y][z];
}
}
}
}
return sum;
}发布于 2012-04-12 04:03:49
如果尝试是多维数组,则需要不同的语法:setItem:sum+= setItem[x,y,z];
https://stackoverflow.com/questions/10113056
复制相似问题