This quiz will test your understanding of C# List Collections, focusing on their functionality, methods, and properties. The questions will cover key concepts such as adding, removing, and sorting items in a list, how to access and modify list elements, and the use of methods like Add(), Remove(), and Sort(). Additionally, you’ll explore how to find items in a list, manage its size with properties like Count and Capacity, and clear lists using methods like Clear() and TrimExcess().
1.
What does the Count property of a C# list represent?
2.
Which property returns the current number of elements in a list?
3.
What does the Clear() method do in a list?
4.
Which method is used to remove excess capacity from a list?
5.
How can you check if a list contains a specific value?
6.
What does the TrimExcess() method do in C# lists?
7.
What does the Add() method do in a List?
8.
How can you initialize a list with several values at once?
9.
Which method is used to remove all elements from a C# list?
10.
What is the difference between the Count and Capacity properties of a C# list?
11.
How can you remove excess capacity from a C# list?
12.
What is one key advantage of C# List over arrays?
13.
How would you retrieve the index of the last occurrence of an item in a list?
14.
What will the IndexOf() method return if the specified item is not found in the list?
15.
Which method would you use to find out if a C# list contains a specific item?
16.
What does the Sort() method do when called on a C# list?
17.
How do you insert an item at a specific position in a C# list?
18.
Which method would you use to remove a specific item from a C# list?
19.
How do you access the second item in a C# list called colorList?
20.
What is the correct way to initialize a list with multiple values in C#?
21.
Which method is used to add an item to a C# list?
22.
How do you declare an empty List in C# that can store strings?