C# arrays are fixed-length: int[] scores = {88, 92, 75};. List<T> from System.Collections.Generic is resizable—the default dynamic collection, similar to ArrayList in Java.
Array and List basics
int[] nums = {10, 20, 30};
List<string> names = new List<string> { "Ada", "Grace" };
names.Add("Alan");
Console.WriteLine(names[0]);
Arrays expose Length; lists use Count. Both support foreach and index access.
When to use which
- Array — fixed size known upfront, interop, performance-sensitive buffers
- List<T> — grow/shrink at runtime, most application collections
Important interview questions and answers
- Q: Array vs List?
A: Array fixed size; List resizable with helper methods likeAddandRemoveAt. - Q: Why generics?
A: Compile-time type safety—no casting from raw collections like pre-generics Java.
Self-check
- Which property gives an array's length?
- Which method adds to a List?
Tip: Default to List<T> for resizable collections—arrays are fixed length and mainly for interop or known-size buffers.
Interview prep
- Array vs List?
Arrays are fixed size with
Length;List<T>is resizable withAdd,RemoveAt, andCount.- Why List<T> over ArrayList?
Generics give compile-time type safety—no casting from raw collections like pre-generics Java.