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

C# C# Objects Encapsulation and Arrays Arrays

Tojo Alex
PLUS
Tojo Alex
Courses Plus Student 13,331 Points

I don't know why its asking me again to specify the array length to be 4 again

I have already done that and I don't know why it keeps asking. Error: arrayType[] variableName = new arrayType[arrayLength]

CodeChallenge.cs
 double[] lapTimes = new double {4};
lapTimes[0] = "2.2" ;

3 Answers

Steven Parker
Steven Parker
231,198 Points

Here's a few hints:

  • when specifying an array length, the length should be enclosed in normal (square) brackets
  • the language allows it, but the challenge doesn't like spaces between the type name and the bracket
  • when setting a numeric value, don't put quotes around the number
Tojo Alex
PLUS
Tojo Alex
Courses Plus Student 13,331 Points

oh I think I made that mistake by accident I already knew that previously:

when specifying an array length, the length should be enclosed in normal (square) brackets

and I'm sure I did the other two though I still have this error : Bummer! Did you declare the 'lapTimes' variable as a 'double[]' or 'var'?

code: double[]lapTimes = new double[4]; lapTimes[0] = 2.2;

Steven Parker
Steven Parker
231,198 Points

Try adding a space between "double[]" and "lapTimes".