Recall & Review
beginner
What is a List<T> in C#?
A List<T> is a generic collection in C# that stores elements of the same type in a dynamic array. It can grow or shrink as needed.
Click to reveal answer
beginner
How do you add an item to a List<T>?
Use the
Add() method. For example: myList.Add(item); adds item to the end of the list.Click to reveal answer
beginner
How do you access an element at a specific position in a List<T>?
Use the indexer with square brackets. For example:
myList[0] accesses the first element.Click to reveal answer
intermediate
What happens if you try to access an index outside the List<T> range?
An
ArgumentOutOfRangeException is thrown because the index is invalid.Click to reveal answer
beginner
How can you find the number of elements in a List<T>?
Use the
Count property. For example: int size = myList.Count;Click to reveal answer
Which method adds an element to a List<T>?
✗ Incorrect
The Add() method appends an element to the end of the List<T>.
How do you get the number of elements in a List<T>?
✗ Incorrect
The Count property returns the number of elements currently in the List<T>.
What type of collection is List<T>?
✗ Incorrect
List<T> is a generic collection that uses a dynamic array internally.
What happens if you access myList[10] when myList has 5 elements?
✗ Incorrect
Accessing an index outside the valid range throws an ArgumentOutOfRangeException.
Which of these methods removes all elements from a List<T>?
✗ Incorrect
The Clear() method removes all elements from the List<T>.
Explain what a List<T> is and how it differs from a regular array.
Think about flexibility and type safety.
You got /4 concepts.
Describe how to add, access, and count elements in a List<T>.
Focus on common operations with List<T>.
You got /3 concepts.