You are developing an application that makes use of a Queue class object named MyQueue.
This Queue class object will be used to store messages sent by the user during application run time.
The application that you are developing provides an interface for administrators and an interface for users to create message reports.
You want to ensure that all user messages stored in the MyQueue object are removed when an administrator selects the reset option.
What should you do?
A.
Use the Enqueue method of the MyQueue object.
B.
Use the Clear method of the MyQueue object.
C.
Use the Dequeue method of the MyQueue object.
D.
Use the TrimToSize method of the MyQueue object.
Explanation:
The clear method sets the Count property of the Queue class object to 0 after removing all the elements from the queue. When you call the Clear method for a Queue object, the capacity of the Queue object is not changed.
Incorrect Answers:
A: You should not use this method because it is used to add a new element at the beginning of a Queue object.
C: You should not use this method because it is used to remove an element at the beginning of a Queue object.
D: You should not use this method because it is used to resize a Queue object.
I agree with the answer. B