HOW TO USE HASHTABLE IN VB.NET.

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 667  View(s)
Ratings:
Rate this:
I want to use Hashtable  in vb.net how to use this please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: How to use Hashtable in vb.net.

    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!