C# › Collections
What is the difference between List<T> and an array (T[]) in terms of resizing?
BeginnerAnswer
An array has a FIXED size determined at creation and can never grow or shrink; List<T> is a dynamically-resizable collection built on top of an internal array that automatically grows (by reallocating and copying to a larger array) as you add elements beyond its current capacity.
int[] fixedArray = new int[3]; // always exactly 3 elements
// fixedArray[3] = 4; // IndexOutOfRangeException
List<int> list = new List<int>();
list.Add(1); list.Add(2); list.Add(3); list.Add(4); // grows automaticallyReal-world example Using List<T> for a shopping cart's items (unknown count ahead of time) versus a fixed array for exactly 7 days of the week.