+ 2

How does the List class work? (System.Collections.Generic)

An array is defined with a specific size. But if I want a array, which grows dynamically, I use the List class (from namespace System.Collections.Generic). But how does this class work? How does the list grow dynamically?

8th Jan 2017, 2:59 PM
Jonas Geiler
Jonas Geiler - avatar
1 ответ
+ 1
Let's say our list is for strings then it will be List <string> ourList = new List <string>(); ourList.Add ("value1"); ourList.Add ("value2"); and so on ... when you need to access any item you can do that using index : string myValue= ourList [0];
8th Jan 2017, 6:59 PM
Ahmad Hamdan
Ahmad Hamdan - avatar