Back to course

List<T> and Generic Collections

.NET Zero to Hero: Master C# and Modern App Development

Lists: Better than Arrays

While arrays have a fixed size, List<T> can grow or shrink dynamically.

Usage:

csharp using System.Collections.Generic;

List fruits = new List(); fruits.Add("Apple"); fruits.Add("Banana"); fruits.Remove("Apple");

Console.WriteLine(fruits.Count);

T represents the type of data (int, string, User, etc.).