// Iterate Over Key–Value Pairs
// Most common pattern
using System;
using System.Collections.Generic;
public class Program
{
public static void Main(string[] args)
{
var dict = new Dictionary<string, int>
{
["Alice"] = 10,
["Bob"] = 17,
["Marley"] = 23,
["Charlie"] = 36
};
foreach (var kvp in dict) {
Console.WriteLine($"Key: {kvp.Key}, Value: {kvp.Value}");
}
}
}
/*
run:
Key: Alice, Value: 10
Key: Bob, Value: 17
Key: Marley, Value: 23
Key: Charlie, Value: 36
*/