Programming in C# — Question 81

You plan to create a list of customers named customers. Each customer will have a name and a key. The name and key will be strings.
You will use the following code to retrieve customers from the list. customers[aKey].toString();
You need to identify which class must be used to declare the customers list. The solution must ensure that each key is unique.
Which class should you identify?

Answer options

Correct answer: B

Explanation

The correct answer is B, Dictionary, as it is designed to store key-value pairs where each key is unique. An ArrayList (A), List (C), and Array (D) do not enforce uniqueness of keys, which is essential for this scenario.