1/15
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
KeyValuePair
A generic value type in System.Collections.Generic that stores a key together with its associated value as a single pair. Domain: C# → .NET → System.Collections.Generic → Key-Value Pairs
TKey
The generic type parameter that specifies the type of the KeyValuePair's key.
TValue
The generic type parameter that specifies the type of the KeyValuePair's value.
new KeyValuePair
Creates a KeyValuePair containing the specified key and value.
pair.Key
Gets the key stored in a KeyValuePair.
pair.Value
Gets the value stored in a KeyValuePair.
KeyValuePair as a Dictionary Entry
Each element obtained when enumerating a Dictionary
KeyValuePair Enumeration
Enumerating a Dictionary allows each KeyValuePair to expose the current entry's key through Key and its associated value through Value.
KeyValuePair Is a Value Type
KeyValuePair
KeyValuePair Is Read-Only
A KeyValuePair's Key and Value properties cannot be directly reassigned after the pair has been created.
KeyValuePair Deconstruction
A KeyValuePair can be deconstructed into separate key and value variables using deconstruction syntax.
var (key, value) = pair
C# syntax that deconstructs a KeyValuePair into separate variables containing its key and value.
foreach (KeyValuePair
Explicitly enumerates the entries of a Dictionary
foreach (var pair in dictionary)
Enumerates dictionary entries while allowing the compiler to infer the corresponding KeyValuePair
KeyValuePair vs Dictionary
A Dictionary
KeyValuePair.ToString()
Returns a string representation of the key-value pair.