Programming in C# — Question 70

You are developing an application that contains a class named TheaterCustomer and a method named ProcessTheaterCustomer. The method accepts a TheaterCustomer object as the input parameter.
ProcessTheaterCustomer()
You have the following requirements:
✑ Store the TheaterCustomer objects in a collection.
✑ Ensure that the ProcessTheaterCustomer() method processes the TheaterCustomer objects in the order in which they are placed into the collection.
You need to meet the requirements.
What should you do?

Answer options

Correct answer: B

Explanation

The correct answer is B because a System.Collections.Queue is designed to handle elements in a first-in, first-out (FIFO) manner, which aligns with the requirement to process TheaterCustomer objects in the order they were added. Option A is incorrect as a Stack processes items in a last-in, first-out (LIFO) manner. Option C is not suitable because a SortedList organizes elements based on keys, not insertion order. Option D does not fulfill the requirement for processing order as an ArrayList does not inherently maintain a FIFO order.