How to use Hashtable in vb.net.

I want to use Hashtable  in vb.net how to use this please help me.
Last updated:12/23/2015 9:48:36 PM

1 Answers

Aditya Patel
Aditya Patel

The Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. It uses the key to access the elements in the collection.

A hashtable is used when you need to access elements by using key, and you can identify a useful key value. Each item in the hashtable has a key/value pair. The key is used to access the items in the collection.

Module Module1
    Sub Main()
        Dim ht As Hashtable = New Hashtable()
        Dim k As String
        ht.Add("001", "anupam singh")
        ht.Add("002", "sunil kumar")
        ht.Add("003", "vinay pawe")
        ht.Add("004", "arjun singh")
        ht.Add("005", "Manish Mishra")
        ht.Add("006", "Manoj Panday")
        ht.Add("007", "Sohel khan")
        If (ht.ContainsValue("Shiv chand")) Then
            Console.WriteLine("This student name is already in the list")
        Else
            ht.Add("008", "Shiv chand")
        End If
        ' Get a collection of the keys.
        Dim key As ICollection = ht.Keys
        For Each k In key
            Console.WriteLine(" {0} : {1}", k, ht(k))
        Next k
        Console.ReadKey()
    End Sub
End Module

 

Answer