Junior From PDF Collections C# Collections

What is the difference between List<T> and ArrayList in C#?

Feature List<T> ArrayList

Generic Yes No

Type Safety Compile-time Runtime (casting required)

Performanc

Better (no boxing) Slower for value types (boxing)

Example:

List<int> list = new List<int>();
list.Add(10); // Type-safe
rrayList arrayList = new ArrayList();

rrayList.Add(10);

int num = (int)arrayList[0]; // Casting required

Best Practice:

lways prefer List<T> in new code. Use ArrayList only when working with legacy

systems.

More from C# Programming Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details