Iterating through a Dictionary Object’s Items in VB.NET

Good example for iterating through dictionary object…

Dim DictObj As New Dictionary(Of Integer, String) 

DictObj.Add(1, “ABC”) 

DictObj.Add(2, “DEF”) 

DictObj.Add(3, “GHI”) 

DictObj.Add(4, “JKL”) 

For Each kvp As KeyValuePair(Of Integer, String) In DictObj 

Dim v1 As Integer = kvp.Key 

Dim v2 As String = kvp.Value 

     Debug.WriteLine(“Key: ” + v1.ToString _ 

            + ” Value: ” + v2) 


For more information, please refer to

(Visited 12 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *