Found 2745 Articles for Csharp

C# Program to Print the Length of the Hashtable

Shilpa Nadkarni
Updated on 22-Dec-2022 18:08:50

391 Views

Hashtable collection in C# is a collection of elements wherein each element consist of key-value pair. The key of the element is unique and non-null while the value of the element can be duplicated or even null. The key-and-value pairs are organized based on the hash code of the key. The key is used to access the elements in the collection. In C#, the class named Hashtable represents the hashtable collection. This class provides various constructors to construct/create the hashtable object. The Hashtable class also provides various methods and properties using which we can manipulate the hashtable collection. Let’s ... Read More

C# Program to Merge Two Hashtable Collections

Shilpa Nadkarni
Updated on 22-Dec-2022 18:03:32

382 Views

The hashtable collection in C# stores key-value pairs. Each element or item in this collection is a key-value pair i.e. this collection is a double-element collection. The Key is unique, non-null, and used to access the elements in the hashtable. The hashtable collection is immutable and cannot have duplicate elements. This means combination of key-value should be unique. However, the values can be null or duplicated. The .Net Framework provides a HashTable class to implement the hashtable collection and contains the required functionality to implement a hashtable without any additional coding. Each element within the hashtable collection is a DictionaryEntry ... Read More

C# Program to Get Key based on Value in Hashtable Collection

Shilpa Nadkarni
Updated on 22-Dec-2022 17:29:42

843 Views

A hash table is a collection in C# that holds items identified as key-value pairs. So unlike other data structures like the stack, queue, or ArrayList in C# that store a single value, hashtable in C# stores 2 values. These 2 values i.e. key-value pair form an element of the hash table. In a hashtable, the keys are unique and should not be null. The values in the hashtable can be null and also duplicated. In C#, the System.collections interface provides a class “Hashtable” which is used to represent the hashtable collection. This class provides various constructors to create a ... Read More

C# Program to Check if Value exists in Hashtable

Shilpa Nadkarni
Updated on 22-Dec-2022 17:22:55

1K+ Views

The hashtable is an organized collection of key-value pairs wherein the keys are arranged as per the hash code of the key calculated using the hash function. While the keys should be non-null and unique in a hashtable, the values can be null and duplicate. The elements in the hashtable are accessed using the keys. In C#, the class “Hashtable” represents the hashtable collection. This class provides various properties and methods using which we can perform operations and access data in the hashtable. In this article, we will see how we can determine if a particular value is present ... Read More

C# Program to Check a HashTable collection is empty or not

Shilpa Nadkarni
Updated on 21-Dec-2022 18:30:37

971 Views

The Hashtable collection in C# is a collection of key-value pairs that are organized based on the hash code of the key. The hash code is calculated using a hash code function. Each element in the hashtable is a key-value pair with unique keys. Keys also have to be nonnull. Values can be null and duplicated. In this article, we will discuss how to check if the hashtable collection is empty. How to Check if the Hashtable Collection is Empty? The class in C# that implements the hashtable collection is the Hashtable class. We can check if the hashtable collection ... Read More

How to Get Value from HashTable Collection in C# using Specified Key

Shilpa Nadkarni
Updated on 22-Dec-2022 18:09:47

5K+ Views

A hashtable is a collection of key−value pairs. We can access key−value pairs using an iterator. We can also access the keys of the hashtable in a collection. Similarly, we can access the values in a hashtable. Given a hashtable, it is also possible to access the value of a specified key or matching key of a specified value. Let’s discuss how we can access a value from the hashtable collection given a key. How to Get Value from Hashtable Collection using Specified Key? Here, we have to obtain a value from the key−value pair of hashtables when a ... Read More

How to get keys from a HashTable in C#?

Shilpa Nadkarni
Updated on 14-Dec-2022 12:04:46

142 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 consists of key/value pairs in which each key is computed as a hash code and stored in a different bucket internally. Whenever the HashTable is accessed, this hash code is matched to the hash code of the specified key and thus the corresponding values are accessed. This mechanism optimizes the lookup in the HashTable. Let’s now discuss how to get keys from a HashTable in C#. How to Get Keys from a HashTable? ... Read More

How to Delete Item from Hashtable Collection in C#?

Shilpa Nadkarni
Updated on 14-Dec-2022 14:01:31

221 Views

The Hashtable in C# is a collection of key−value pairs that are organized based on the hash code of the key. The items in the hashtable are accessed using a key. The Hashtable class of C# is the class that implements the hashtable. Using this class, we can create a new hashtable object with the help of the constructors provided. The Hashtable class also provides various methods using which we can perform various operations on the hashtable. These operations include adding items, checking for the existence of specified keys, counting the number of items, removing an item from the hashtable, ... Read More

How to Create a HashTable Collection in C#?

Shilpa Nadkarni
Updated on 14-Dec-2022 11:49:16

128 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
Updated on 14-Dec-2022 11:47:21

1K+ 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

Previous 1 ... 6 7 8 9 10 ... 275 Next
Advertisements