Display the contents of the collection using the enumerator
Imports System
Imports System.Collections
Imports System.Collections.Specialized
Public Class SamplesStringDictionary
Public Shared Sub Main()
Dim myCol As New StringDictionary()
myCol.Add("red", "R")
myCol.Add("green", "G")
myCol.Add("blue", "B")
PrintKeysAndValues2(myCol)
End Sub
Public Shared Sub PrintKeysAndValues2(myCol As StringDictionary)
Dim myEnumerator As IEnumerator = myCol.GetEnumerator()
Dim de As DictionaryEntry
While myEnumerator.MoveNext()
de = CType(myEnumerator.Current, DictionaryEntry)
Console.WriteLine(" {0,-25} {1}", de.Key, de.Value)
End While
End Sub
End Class
Related examples in the same category