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 trialYiu Ming Lai
5,861 PointsAnyone know why i am getting "Object reference not set to an instance of an object"?
Anyone know why i am getting "Object reference not set to an instance of an object"?
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[][] BuildMultiplicationTable(int maxFactor)
{
int [][] arr = new int [maxFactor][];
for (int row = 0; row <= maxFactor; row++)
{
for (int col = 0; col <= maxFactor; col++)
{
arr[row][col] = row*col;
}
}
return arr;
}
}
}
1 Answer
D O
7,353 PointsYou need to initialize your column arrays first before you start assigning values. Someone had the same question here: https://teamtreehouse.com/community/c-collections-challenge-task-jagged-arrays