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) 

Next

For more information, please refer to http://msdn.microsoft.com/en-us/library/xfhwa508.aspx

(Visited 6 times, 1 visits today)

Leave a Reply

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