C# C# Objects Encapsulation and Arrays Arrays

kal alben-mccave
kal alben-mccave
2,305 Points

C# array code challenge

Hey guys any help given would be appreciated, cant seem to get the last part of the code right. Thanks

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

lapTimes[0] = 2.2;

double[] finalLapTimes = new double[4] {2.2,2.3,2.5,2.8};

double lap3 = finalLapTimes[3]

2 Answers

<noob />
<noob />
16,621 Points

Good job! You are really close.

in this line u can find the problem :

double lap3 = finalLapTimes[3]

you need to assign lap3 to the third item in the array. how u access element in array in c# >> by their index!. so you want to access the THIRD element which is in INDEX 2 since array start in INDEX 0.

so the solution is:

double lap3 = finalLapTimes[2]
kal alben-mccave
kal alben-mccave
2,305 Points

thanks bro I appreciate it, worked well