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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Stephen Mooney](https://secure.gravatar.com/avatar/e4242949c372f91aa45cb69b15b47694?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Stephen Mooney
2,794 PointsCan someone please explain the basics of jagged arrays? i know i have to multiple the rows by the columns
help please
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[][] BuildMultiplicationTable(int maxFactor)
{
}
}
}
3 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsPerhaps the most important thing to bear in mind about jagged arrays are that they are nested. So your master array will have other arrays inside it, each of which will need to be separately declared and initialized.
Also, remember that array index numbers start at 0, so the highest valid index will be one less than the array size (or perhaps I should say the array size needs to be one more then the highest index you will use). This will be handy for establishing loop limits as well as declaring the arrays.
Hopefully those hints will get you going.
![David Tomko](https://secure.gravatar.com/avatar/b4a575aaf13e29110a11fea34c11e76e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
David Tomko
7,744 PointsThis one I struggled on too, but here is my code
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[][] BuildMultiplicationTable(int maxFactor)
{
int[][] table = new int[maxFactor + 1][];
for(int row = 0; row < table.Length; row++)
{
//here we are creating the actual rows of the array that have "maxFactor" + 1 columns
table[row] = new int[maxFactor + 1];
for(int col = 0; col < table[row].Length; col++)
{
table[row][col] = row * col; // This is where we actually are giving the values to the array
}
System.Console.WriteLine(); //This creates a new line between every row in the array so everything isn't on one line
}
return table;
}
}
}
![David Tomko](https://secure.gravatar.com/avatar/b4a575aaf13e29110a11fea34c11e76e?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
David Tomko
7,744 PointsSteven Parker the explanation is in the comments of my code. For me this is how I learn best if I have an issue that someone has already solved I like to see their code just so I can see the differences between theirs and mine. While also walking step by step through their code to see exactly what's going on.
![David Tomko](https://secure.gravatar.com/avatar/b4a575aaf13e29110a11fea34c11e76e?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
David Tomko
7,744 PointsSteven Parker it's all good man, no worries!
![Stephen Mooney](https://secure.gravatar.com/avatar/e4242949c372f91aa45cb69b15b47694?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Stephen Mooney
2,794 PointsThanks guys. Does anyone know of any business case a jagged array have been used for?
Finance or engineering maybe? But what about sme not in these areas?
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThis is a pretty generic concept, I'm sure both jagged and multi-dimension arrays are used in all those and many other cases where data is organized in tables or a layered fashion.
![Keith Whatling](https://uploads.teamtreehouse.com/production/profile-photos/4093202/micro_FinalSelect_Microsoft_PowerPlatform_London_KeithWhatling_1818-1_V3.jpg)
Keith Whatling
17,759 PointsI think a good example of jagged arrays would be an information send list. Say you had 10 users who wanted reports on the number of cars in their business, each user may have different a amount of cars. a Jagged Array would be a great collection to use to lookup the cars by user and send them the data for X car.