Index-based Input/Output — in which of the following .NET collections are elements accessed by index?
C# Programming
Collection Classes
Difficulty: Easy
Choose an option
-
AStack and Queue
-
BBitArray and ArrayList
-
CHashTable only
-
DStack, Queue, and HashTable
-
EAll of the above
Answer
Correct Answer: BitArray and ArrayList
Explanation
Introduction / Context:Different collection types expose different access patterns (index, key, FIFO, LIFO). This affects algorithm design and complexity.
Concept / Approach:ArrayList and BitArray are index-based. Stack (LIFO) and Queue (FIFO) do not expose random indexers. HashTable is key-based, not index-based.
Why Other Options Are Wrong:Options including Stack/Queue/HashTable imply index-based access where none exists.
Final Answer:BitArray and ArrayList