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 trialName:GoogleSearch orJonathan Sum
5,039 PointsWhy this code doesn't work?
It works in REPL.
it prints
0000000000
0123456789
024681012141618
0369121518212427
04812162024283236
051015202530354045
061218243036424854
071421283542495663
081624324048566472
091827364554637281
However, it doesn't work when i try to run this code. ``cs namespace Treehouse class Cell3 {
int[][] sheet = new int[10][];
sheet[0] = new int[10];
for(int rowIndex = 0; rowIndex < sheet.Length; rowIndex++)
{
sheet[rowIndex] = new int[10]; //creata row of 10 cells
for(int colIndex = 0; colIndex < sheet[rowIndex].Length; colIndex++)
{
sheet[rowIndex][colIndex] = rowIndex*colIndex;
}
}
}
1 Answer
Steven Parker
231,210 PointsDo you mean when you "try to compile this code"?
The REPL lets you experiment with code bits that are not a complete program. To compile and run a program, you'll need to add a bit of "boilerplate", including a class and static Main method to contain the executable part of your code.
Name:GoogleSearch orJonathan Sum
5,039 PointsName:GoogleSearch orJonathan Sum
5,039 PointsI don't know how. Could u just post the code?
Name:GoogleSearch orJonathan Sum
5,039 PointsName:GoogleSearch orJonathan Sum
5,039 PointsOf couse i did try to compile this code and adding class. However, it said it won't work ,brother!