I’m trying create a method that returns the sum of all values in an array list. I’m getting an error on this line sum+= setItem[x][y][z]; The error is
expression must have pointer-to-object or handle-to-CLI-array type c:\Development\Source\Source\Source.cpp
full function
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;
}
If
setItemis multidimensional array, you need a different syntax: Try:sum+= setItem[x,y,z];