You can use a generic list, defined by the List<T> class, to store a dynamically sized collection of objects. A List<T>can store any type of object, including both value-typed and referenced-typed objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // List of integersList<int> favNumbers = new List<int>();<span class="skimlinks-unlinked">favNumbers.Add(5</span>);<span class="skimlinks-unlinked">favNumbers.Add(49</span>);// List of Dog objectsList<Dog> myDogs = new List<Dog>();<span class="skimlinks-unlinked">myDogs.Add(new</span> Dog("Kirby", 15));<span class="skimlinks-unlinked">myDogs.Add(new</span> Dog("Ruby", 3));// List of structsList<Point3D> points = new List<Point3D>();<span class="skimlinks-unlinked">points.Add(new</span> Point3D(1.0, 1.0, 0.5, "Here"));<span class="skimlinks-unlinked">points.Add(new</span> Point3D(2.0, 2.0, 0.5, "There")); |

