Generic list

As you can see, the ArrayList class contains a broad range of features, but it has a significant drawback—it is not a strongly typed list. If you want to benefit from a strongly typed list, you can use the generic List class representing the collection, whose size can be increased or decreased, whenever necessary.

The generic List class contains many properties and methods that are very useful while developing applications that store data. You will see that many members are named exactly the same as in the ArrayList class, such as Count and Capacity properties, as well as the Add, AddRange, Clear, Contains, IndexOf, Insert, InsertRange, LastIndexOf, Remove, RemoveAt, RemoveRange, Reverse, and ToArray methods. You can also get ...

Get C# Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.