Created by Thiago Avelino
over 8 years ago
|
||
Question | Answer |
What are the collections namespace? | System.Collections.Generic classes System.Collections.Concurrent classes |
What are the common Generics Lists? | Dictionary - Key value pair List - value Stack - LIFO Queue -FIFO SortedList - Key value pair ordered by the key |
How to add an element in a Dictionary? | dictionay.Add(key, value); or dictionary[key] = value; |
Can keys be duplicated? If not what is the exception expected when it happens? | No, they cannot.The exception expected is ArgumentException |
How to search an item on a Dictionary? | dictionary.Contains(key); |
How to check if an item is on a list? | List.Contains(item); |
What is the default capacity of the common collections? | Stack - 10 List - 0 Dictionary - system default SortedList - 0 Queue - system default |
What is the implementation of a Dictionary and performance of data retrieval? | Retrieving a value by using its key is very fast, close to O(1), because the Dictionary<TKey, TValue> class is implemented as a hash table. |
What is the difference between Hashtable and Dictionary? | 1. Hashtable is slower than dictionary. 2. Dictionary returns error when trying inexistent keys. Hashtable returns null. 3. Dictionary has generic type, hashtable doesn't have that. 4 . Hashtable is thread safe, dictionay is only for static members. |
What is a LinkedList? | It is a list that you can navigate on the nodes. Each node has the reference of the next and the previous node. |
What are the interfaces required for a custom collection and why? | IEnumerator: Supports a simple iteration over a non-generic collection. IEnumerable: Exposes an enumerator, which supports a simple iteration over a non-generic collection. |
What is the item's data structure of a dictionary? | KeyValuePair<TKey, TValue> |
When use the ListDictionary? | When you have less than 10 items on the collection. |
When use the HybridDictionary? | The HybridDictionary is a collection that optimizes the performance of the Dictionary. That happens because for small collections it uses ListDictionary as implementation but it automatically switches to HashTable when the collection gets bigger, |
What is the namespace of the simple Array object []? | System.Array |
Want to create your own Flashcards for free with GoConqr? Learn more.