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 trialTojo Alex
Courses Plus Student 13,331 Pointsi'm not sure what to do here
I've kept on trying to work out what I did wrong but I can't crack the code. Help requested.
namespace Code
{
class code
{
string[] laptimes = new string[4];
}
}
6 Answers
Joe Beltramo
Courses Plus Student 22,191 PointsThere is no need for a namespace or class.
Instructions are: Declare an array of doubles named lapTimes of length 4.
Tojo Alex
Courses Plus Student 13,331 Pointsoh thanks and cool profile
Tojo Alex
Courses Plus Student 13,331 Pointsi just have one more error : Did you declare the array to be of type 'double'?
var double[] lapTimes; string[] lapTimes = new string[4];
Joe Beltramo
Courses Plus Student 22,191 PointsNo need for the keyword var
and an array of type double
cannot be assigned a new array of type string
Tojo Alex
Courses Plus Student 13,331 Pointsnow I have this error : StudentsCode.cs(8,10): error CS0128: A local variable named `lapTimes' is already defined in this scope Compilation failed: 1 error(s), 0 warnings
code: double[] lapTimes; string[] lapTimes = new double[4];
Joe Beltramo
Courses Plus Student 22,191 Pointsdouble[] lapTimes = new double[4];
That is the only code you need to do.
As an explanation inline you are writing:
arrayType[] variableName = new arrayType[arrayLength]
Does that make sense?
Tojo Alex
Courses Plus Student 13,331 Pointsthanks I also realized that i have spelt the variable wrong