Advertisement
Beginner C#, Collections

When would you use a List<T> vs an array?

Short answer

Use an array for a fixed-size, performance-critical buffer; use List when the count changes, since it grows and offers Add/Remove/Insert.

Save C# mock interview
Advertisement
AModel answer
Use an array for a fixed-size, performance-critical buffer; use List<T> when the count changes, since it grows and offers Add/Remove/Insert.
int[] fixedGrid = new int[9];
var items = new List<string>(); items.Add("a");
Real-world example
A game board is an array; a shopping cart is a List<T>.