Back to Home

C# string[] vs List<string>: Which Should You Use?

Use an array when the size is fixed and known up front. Use a List<string> when you need to add or remove elements dynamically.

Quick comparison

TypeBest forSizeCommon methods
string[]Fixed-size data, simple containersFixedLength, indexing
List<string>Dynamic collections, growing inputFlexibleAdd, Remove, Contains, Count

Array example

C# Example Code
string[] names = { "Alice", "Bob", "Carol" };
Console.WriteLine(names[0]);

List example

C# Example Code
var names = new List<string> { "Alice", "Bob" };
names.Add("Carol");
Console.WriteLine(names.Count);

Converting between them

C# Example Code
string[] array = { "one", "two", "three" };
List<string> list = array.ToList();

string[] fromList = list.ToArray();

FAQ

Which is faster?

Arrays are slightly lighter and simpler for fixed-size data. Lists are more convenient for changing collections.

When should I prefer a list?

Prefer List<string> when the number of items is unknown or grows while the program runs.

Take It Further

C# 12 and .NET 8 book cover

The most comprehensive book covering C# 12 and .NET 8 from scratch to production.

C# 12 and .NET 8 — Modern Cross-Platform Development · Mark J. Price

Get it on Amazon →

As an Amazon Associate I earn from qualifying purchases.