VB.NET HashTable: In Hash Table, the storing process of several varieties of data is performed in the Key-Value Pairs. In this table, the organization of data is based upon a Hash Key.
Hash table
 helps in increasing faster lookups in comparison with any other key. In return, it provides a pre-specified value. The concept in the Hash Table is about adding Keys and Values with each other. The HashTable is also known as an optimized Lookup Mechanism. A HashTable is provided by the System.Collection namespace. The process of identifying and accessing elements in HashTable is done with the help of Key. This is done because every element in HashTable has a Key and Value pair. 

HashTable Properties

1. IsSynchronized – This property helps in verifying that HashTable is synchronized or not.

2. IsFixedSize – This property helps in verifying that HashTable has a fixed size.

3. Count This property helps in counting the no. of elements of the key and value pairs that are present in the HashTable.

4. IsReadOnly – This property helps in verifying that HashTable is read- only or not.

5. Item – This property helps in getting and setting values that are related to the particular key.

6. Keys – This property helps in collecting the keys within HashTable.

7. Values – This property helps in collecting the values within HashTable.

HashTable Methods

1. Add – This method helps in adding the item having a particular key and value in Hashtable.

Syntax –

2. ContainsKey – This method helps in verifying that the particular key exists in the HashTable.

Syntax –

3. ContainsValue – This method helps in verifying that the value of particular key is present in HashTable or not.

Syntax: 

4. Remove – This function helps in removing the particular key with value from the table.

Syntax: 

5. Clear – This method helps in removing all the items in the HashTable.

6.Get Hash – This method helps in getting Hash Code of particular key in the HashTable.

Let’s create a program to understand the concept of HashTable in the VB.NET programming language.

Example 1 – Write a program to show the use of HashTable.

Input

Hash_Array.vb

Output:

VB.NET HashTable

Example 2. Write a program to show the use of Hash Table.

Input-

Output:

VB.NET HashTable

Example 3. Write a program to show the use of HashTable.

Input

Output:

VB.NET HashTable

Pin It on Pinterest

Share This