Imports System.Collections
public class Test
public Shared Sub Main
Dim myTable As New Hashtable
Dim objKey As Object
Dim objValue As Object
'Populate the hash table.
myTable.Add("H", 1)
myTable.Add("L", 2)
'Check before inserting another value.
If Not myTable.ContainsKey("A") Then
myTable.Add("A", 78)
End If
'Remove a value.
myTable.Remove("L")
'Display the hash table values.
Console.WriteLine("The hash table contains " & myTable.Count & " elements.")
For Each objKey In myTable.Keys
objValue = myTable.Item(objKey)
Console.WriteLine("ELEMENT KEY: " & objKey.ToString & vbCrLf & _
"ELEMENT VALUE: " & objValue.ToString)
Next objKey
End Sub
End class
The hash table contains 2 elements.
ELEMENT KEY: A
ELEMENT VALUE: 78
ELEMENT KEY: H
ELEMENT VALUE: 1