Junior
From PDF
Collections
C# Collections
What is the significance of the KeyValuePair<TKey, TValue> structure in Dictionary?
KeyValuePair<TKey, TValue> represents a single item in a dictionary — a key-value
pair.
Used in:
- Iteration
- LINQ queries
- Return values from dictionary enumerators
Example:
foreach (KeyValuePair<string, int> entry in dictionary)
{
Console.WriteLine($"Key: {entry.Key}, Value: {entry.Value}");
}Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png