Shilpa Nadkarni

Shilpa Nadkarni

13 Articles Published

Articles by Shilpa Nadkarni

Page 2 of 2

How to Create a HashTable Collection in C#?

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 14-Dec-2022 285 Views

The HashTable is a non−generic collection in C#. It stores key-value pairs and is similar to a generic “Dictionary” collection. HashTable is defined in System. Collections. namespace. HashTable computes the hash code of each key and stores it in a different bucket internally. The hash code is then matched to the hash code of the specified key when the values are accessed. Thus the lookups are optimized by HashTable. In this tutorial, we will see how we can create a HashTable collection in C#. Hashtable Features Before we jump to creating a HashTable, let us see some of ...

Read More

How to Check if a Key Exists in the Hashtable in C#?

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 14-Dec-2022 2K+ Views

The Hashtable class in C# represents a collection of key-value pairs. These key-value pairs are organized based on the hash code of the key that is calculated using the hash code function. The key in the hashtable accesses the items. So given a key, we can access the corresponding value for that key in the hashtable. The keys in the hashtable are unique and non-null. The values however can be null or duplicated. We have been discussing hashtable topics in our earlier tutorials. We continue the trend in this article as well. In this article, we will discuss how to ...

Read More

How to Add Items to Hashtable Collection in C#

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 14-Dec-2022 888 Views

We have already discussed the basics of hashtables. A hashtable collection in C# is used to store key−value pairs wherein each of these key-value pairs is organized based on the hash code of the key. This hash code is calculated using a hash code function. Internally, the hashtable uses buckets to store data. A bucket is nothing but a virtual group of elements within the hashtable. A hash code is associated with each bucket. Programmatically, a hashtable is similar to a dictionary object but unlike in dictionary object, a hashtable can store objects of different data types. Performance−wise, hashtables exhibit ...

Read More
Showing 11–13 of 13 articles
« Prev 1 2 Next »
Advertisements