Skip to content
Justice Tech School

C# Lists

List<T> is a resizable list. Add, Remove, Contains, IndexOf, Sort and Count are the common members. It is used far more than raw arrays.

Example
var fruits = new List<string> { "apple", "banana" };
fruits.Add("cherry");
fruits.Remove("banana");
Console.WriteLine(string.Join(", ", fruits));
Console.WriteLine(fruits.Count + " " + fruits.Contains("apple"));

Exercise

Add an item.

list.("x")

Quiz Test

Which type resizes?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.