Back to course

Working with Lists

C# Zero to Hero: Comprehensive Programming Masterclass

Lists in C#

Unlike Arrays, Lists are dynamic. They can grow or shrink in size automatically.

Creating a List

You need to use using System.Collections.Generic;.

csharp List names = new List(); names.Add("John"); names.Add("Jane");

names.Remove("John"); Console.WriteLine(names.Count);

Benefits

  • Dynamic sizing.
  • Built-in methods for sorting and searching.