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 Reading Line By Line

Aaron Selonke
Aaron Selonke
10,323 Points

List vs Array

When explaining the benefit of an List over an Array Carling says that "Lists do not have a fixed link, like an array"

What is a fixed link?

alt text

Well..... What is a fixed link?......... Fixed size means that in the array initializing you specify an actual size whether using a number between the square brackets just like this:

<p>string[] array = new string[9];</p>

or also like this using the var keyword (which you may use a lot in your code) :

<p>var array = new string[9];</p>

or otherwise using a object initializing syntax just like this:

<p>string[] array = new string{0, 1, 2, 3, 4, 5, 6, 7, 8};</p>

or:

<p>var array = new string[]{0, 1, 2, 3, 4, 5, 6, 7, 8};</p>

==================================== After you have done this you cant change the size of the array so if you filled the array you cant add any more items or otherwise if you filled just 4 items (assuming that the size of the array is five)

so this could be a abuse for the memory if filled items less than the array size or it could abuse for you as developer because you will have to create a very hard coded methods to solve this problems.

Unlike the list (which lives in System.Collections.Generic) takes a type pararmter (if you are not familier with the concepts of "Generics" in software development you can read this article:

https://msdn.microsoft.com/en-us/library/ms379564%28v=vs.80%29.aspx?f=255&MSPPError=-2147217396

or you can read this also (as the previous one is an inroduction):

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/

so back to our topic: in the List<T> type you can modify the size of the list throw the methods: Add(TItem); or Remove(TItem)

and so so many methods

hope you understood what i`m trying to say Greetings :) :)

1 Answer

Steven Parker
Steven Parker
231,198 Points

:point_right: You've found a bug in the video captions and transcript.

What is actually said on the video is "a list doesn't have a fixed length like an array does."

This number of items in an array is determined when the array is created, but in a list items may be added or removed at any time.

You may want to report that bug using the instructions on the Support page. :beetle: It might even get you "a special Exterminator badge".