Hashtable.Add Method adds an element with the specified key and value into the Hashtable.
Imports System
Imports System.Collections
Public Class SamplesHashtable
Public Shared Sub Main()
Dim myHT As New Hashtable()
myHT.Add("one", "The")
myHT.Add("two", "quick")
myHT.Add("three", "brown")
myHT.Add("four", "fox")
PrintKeysAndValues(myHT)
End Sub 'Main
Public Shared Sub PrintKeysAndValues(myHT As Hashtable)
Dim de As DictionaryEntry
For Each de In myHT
Console.WriteLine(vbTab + "{0}:" + vbTab + "{1}", de.Key, de.Value)
Next de
End Sub
End Class
Related examples in the same category