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

Hermes Crespo
Hermes Crespo
980 Points

My code obviously shows that I declared the array variable as double so why am I getting the message that i need to....

... declare the array variable as double?? I coded: double[] lapTimes = new lapTimes[4];

CodeChallenge.cs
double[] lapTimes = new lapTimes[4];

1 Answer

You are close, in declaring an array, you want to initialize it with the type, not the name of the variable itself. Since there is no way to explain without actually giving you the answer, welp, here it is:

double[] lapTimes = new double[4]; // Notice using the type `double` instead of lapTimes by the instantiation of length
Hermes Crespo
Hermes Crespo
980 Points

Thanks! I did do something similar but had left a space as so: new double [4] ... thus, also got an error message. But now I know better thanks to you. Thanks again!