' Iterate Over Key–Value Pairs
' Most common pattern
Imports System
Imports System.Collections.Generic
Public Module Program
Public Sub Main(args As String())
Dim dict As New Dictionary(Of String, Integer) From {
{"Alice", 10},
{"Bob", 17},
{"Marley", 23},
{"Charlie", 36}
}
For Each kvp In dict
Console.WriteLine($"Key: {kvp.Key}, Value: {kvp.Value}")
Next
End Sub
End Module
' run:
'
' Key: Alice, Value: 10
' Key: Bob, Value: 17
' Key: Marley, Value: 23
' Key: Charlie, Value: 36
'