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 trialMohammed Abdalla
7,448 Pointsi think that i have a problem with my index, but i am not able to discover my mistake
2 Dim Array
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[,] BuildMultiplicationTable(int maxFactor)
{
int[,] towDimArray = new int[maxFactor,maxFactor];
for(int x =0 ; x < towDimArray.GetLength(0);x++)
{
for(int y =0 ; y < towDimArray.GetLength(1);y++)
{
towDimArray[x,y] = x*y ;
}
}
return towDimArray;
}
}
}
2 Answers
Steven Parker
231,269 PointsYour array is a bit too small.
Since indexes begin at 0, but you want your table to go up to and including the value of maxFactor, your dimensions need to be one larger than maxFactor.
Otherwise, good job!
Mohammed Abdalla
7,448 PointsI got it, thanks a lot