Data Collections Flashcards
What is the primary purpose of data collections in C# .Net?
To store and manage groups of related data.
True or False: Arrays in C# are fixed in size after they are created.
True.
Fill in the blank: The __________ collection is used for storing key-value pairs.
Dictionary.
What is the main difference between List<T> and Array in C#?</T>
List<T> is dynamic in size while Array is fixed in size.</T>
Which data collection type would you use for a collection that requires unique elements?
HashSet.
What interface do all collection types in C# implement?
IEnumerable.
True or False: A Queue in C# follows a Last In First Out (LIFO) order.
False.
What collection type is best suited for implementing a stack in C#?
Stack<T>.</T>
What does the ‘T’ represent in List<T>?</T>
Type parameter.
Which collection allows duplicates and maintains the order of elements?
List<T>.</T>
What is the primary use of the ConcurrentBag<T> collection?</T>
To store a collection of objects that can be accessed by multiple threads.
Fill in the blank: A __________ is a collection that can be accessed in a thread-safe manner.
Concurrent collection.
What collection type would you use for a first-in, first-out (FIFO) access pattern?
Queue<T>.</T>
True or False: The Dictionary<TKey, TValue> collection allows duplicate keys.
False.
What method is used to add an element to a List<T>?</T>
Add().
Which collection type is best for implementing a lookup table?
Dictionary<TKey, TValue>.
What is the default capacity of a List<T> when it is created?</T>
0.
True or False: A LinkedList<T> allows access to elements by index.</T>
False.
What is the time complexity of accessing an element in a List<T> by index?</T>
O(1).
What collection would you use to store a fixed-size collection of objects?
Array.
Fill in the blank: The __________ class provides a way to store a collection of objects in a sorted order.
SortedList.
What is the primary advantage of using a HashSet?
It provides fast lookup times for unique elements.
Which method removes all elements from a collection in C#?
Clear().
True or False: A Stack<T> allows random access to elements.</T>
False.