Search⌘ K
AI Features

Generic List

Explore the generic List<T> class in C# to understand how to create and manage strongly typed dynamic collections. Learn key operations such as adding, removing, and inserting elements, optimizing list capacity, and using built-in sorting and searching features to build efficient applications.

Introduction

The ArrayList class solved the issues we had with arrays, but it also introduced new issues. .NET developers addressed the concerns with a set of generic collection classes. This lesson focuses on the List<T> class. Instead of using an object[] type array, like ArrayList does, generic collections use parameter types. In the case of List<T>, the internal array is of type T[]. Generic collections introduce strong typing. The List<int> class can only store int items, and List<string> can only store ...