Classes and Objects in C#
15 questions · 12 min · Medium
Test your knowledge of collection classes in C#, including ArrayList, Hashtable, List, Dictionary, Queue, Stack, and other collection concepts.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
15 questions · 12 min · Medium
15 questions · 12 min · Medium
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
A. System.Collections
The System.Collections namespace contains non-generic collection classes such as ArrayList, Hashtable, Queue, and Stack.
C. List<T>
List<T> is a generic collection that stores elements of a specified type and provides strongly typed access.
B. Dictionary<TKey, TValue>
Dictionary<TKey, TValue> stores values using unique keys that are associated with each value.
B. Queue<T>
A Queue<T> follows FIFO, meaning the first element added is normally the first element removed.
C. Stack<T>
A Stack<T> follows LIFO, meaning the most recently added element is normally the first one removed.
B. ArrayList
ArrayList is a non-generic collection that can store objects of different types. Generic collections are generally preferred for type safety.
A. HashSet<T>
HashSet<T> is designed to store unique elements and does not allow duplicate elements according to its equality comparer.
B. Add()
The Add() method appends an element to a List<T>.
C. Enqueue()
Enqueue() adds an element to the end of a Queue<T>.
A. Push()
Push() adds an element to the top of a Stack<T>.
C. Dequeue()
Dequeue() removes and returns the element at the beginning of a Queue<T>.
B. Pop()
Pop() removes and returns the element at the top of a Stack<T>.
B. They provide compile-time type safety
Generic collections specify the element type, reducing invalid type assignments and avoiding many unnecessary casts.
A. Dictionary<TKey, TValue>
Dictionary<TKey, TValue> provides a key-value mapping where each key must be unique within the dictionary.
A. IEnumerable
IEnumerable provides the basic mechanism for obtaining an enumerator, allowing a collection to be traversed with foreach.