Home > DeveloperSection > Forums > How to use Hashtable in vb.net.
Ankit Singh

Total Post:341

Points:2389
Posted on    December-23-2015 9:47 PM

 VB.Net VB.Net  Hashtable 
Ratings:


 1 Reply(s)
 290  View(s)
Rate this:
I want to use Hashtable  in vb.net how to use this please help me.


aditya kumar Patel

Total Post:242

Points:1722
Posted on    December-23-2015 9:48 PM

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

 


Don't want to miss updates? Please click the below button!

Follow MindStick