1/28
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Dictionary
A generic collection in System.Collections.Generic that stores associations between unique keys and values, allowing values to be accessed through their corresponding keys. Domain: C# → .NET → System.Collections.Generic → Dictionary
TKey
The generic type parameter in Dictionary
TValue
The generic type parameter in Dictionary
Key-Value Pair
An association in which a unique key identifies and provides access to a corresponding value.
new Dictionary
Creates an empty Dictionary
Dictionary Initializer
Syntax that creates a Dictionary and supplies its initial key-value entries inside braces.
dictionary.Count
Gets the number of key-value pairs currently stored in the Dictionary.
dictionary[key]
Gets or sets the value associated with the specified key.
Dictionary Key
A value used to uniquely identify and retrieve an associated value from a Dictionary.
Dictionary Value
The data associated with a particular key; unlike keys, duplicate values are allowed.
Unique Dictionary Keys
A Dictionary cannot contain multiple entries with equal keys according to its key comparer.
Duplicate Dictionary Values
A Dictionary may contain multiple different keys that are associated with equal values.
dictionary.Add(key, value)
Adds a key and its associated value to the Dictionary and throws an exception if an equivalent key already exists.
dictionary[key] = value
Adds a new key-value association if the key does not exist, or replaces the value associated with an existing key.
dictionary.TryAdd(key, value)
Attempts to add a key-value pair and returns false rather than throwing because the key already exists.
dictionary.ContainsKey(key)
Determines whether the Dictionary contains the specified key.
dictionary.ContainsValue(value)
Determines whether the Dictionary contains at least one entry with the specified value.
dictionary.TryGetValue(key, out value)
Attempts to retrieve the value associated with a key and reports whether the key was found.
dictionary.Remove(key)
Removes the entry associated with the specified key and reports whether the key was found and removed.
dictionary.Clear()
Removes all key-value pairs from the Dictionary.
dictionary.Keys
Gets a collection containing the keys stored in the Dictionary.
dictionary.Values
Gets a collection containing the values stored in the Dictionary.
dictionary.Comparer
Gets the equality comparer used to determine whether dictionary keys are equal.
KeyNotFoundException
The exception typically thrown when the Dictionary indexer is used to retrieve a key that does not exist.
ArgumentException on Add
Dictionary.Add throws an ArgumentException when an equivalent key already exists in the Dictionary.
Dictionary Lookup
A Dictionary is designed for efficient retrieval of values by key rather than retrieval by a sequential numeric position.
Dictionary Enumeration
Enumerating a Dictionary produces KeyValuePair
Dictionary vs List
List
Dictionary Does Not Guarantee Positional Indexing
A Dictionary key is an identifier used for lookup and should not be confused with the zero-based positional index used by List