Which collection type should you use?

You are developing an application that includes a class named Order. The application will
store a collection of Order objects.
The collection must meet the following requirements:
Use strongly typed members.
Process Order objects in first-in-first-out order.
Store values for each Order object.
Use zero-based indices.
You need to use a collection type that meets the requirements.
Which collection type should you use?

You are developing an application that includes a class named Order. The application will
store a collection of Order objects.
The collection must meet the following requirements:
Use strongly typed members.
Process Order objects in first-in-first-out order.
Store values for each Order object.
Use zero-based indices.
You need to use a collection type that meets the requirements.
Which collection type should you use?

A.
Queue<T>

B.
SortedList

C.
LinkedList<T>

D.
HashTable

E.
Array<T>



Leave a Reply 3

Your email address will not be published. Required fields are marked *


PaulC

PaulC

When considering requirements:

Strongly typed members, which means in definition.

Queue or LinkedList (Array cant be defined this way)
LinkedList doesnt process objects in FIFO, moreover its absolutelly wrong approach for Order processing.

Queue is correct.

HINT: whenever in test you read FirstInFirstOut process, its Queue. In case of FILO its Stack.

Maurizio

Maurizio

What about
Use zero-based indices?

Queue cannot be access through index. I think the only way for do this could be:
queue.ToArray()[0];