Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAllan Blain
2,418 PointsI need help with creating the multidimensional array that takes a MaxFactor argument.
It seems I am not setting entering the correct arguments in the square brackets for the array.
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[,] BuildMultiplicationTable(int maxFactor)
{
int[,] arr = new int[maxFactor];
for (int x = 0; x <= maxFactor; x++)
{
arr[x] = new int[x];
for (int y = 0; y <= maxFactor; y++)
{
arr[x, y] = x * y;
}
}
return arr;
}
}
}
1 Answer
Steven Parker
231,198 PointsIt looks like you haven't been consistent with the dimensions.
You correctly declare "arr" as a 2-dimensional array, but on the same line you assign it to a scalar (one-dimension) array. You also treat is as a scalar array inside the first loop (that line is unneeded and can be removed).
Also remember the array size must be one larger the than largest index value (maxFactor).