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# Streams and Data Processing Parsing Data Working with Enums

Syed Abbas
Syed Abbas
4,762 Points

Arrays in soccer game results

Hi I am confused about how arrays are used in this video. Because the soccer result sheet has rows and columns, I cant figure out how it can be arranged in one dimensional arrays. When the values are stored in the array 'values' then it should be a very long array of about about 1790 values. How can a property be set by just referring to , for example, values[1]. I am very confused.? I hope I make sense. Thank you.

2 Answers

andren
andren
28,558 Points

The values array does not contain all of the rows and columns, it only contains one row of info at a time.

The values array is defined within a loop, this loop runs once for each line in the soccerGameResults.csv file. Within this loop line contains all of the text from the row the loop is currently on. The split command is used to turn that row into an array that contains all of the individual columns. So if you had a row like this:

8/26/2015 05:30 PM,Chicago Fire,Home,3,16,5,11,48.68

Then values[0] would equal "8/26/2015 05:30 PM", values[1] would equal "Chicago Fire" and so on.

When the loop moves on to the next line/row the values array is redefined with the split values of that row.

Syed Abbas
Syed Abbas
4,762 Points

Thank you for you reply. It makes sense now.