Server Side Programming Articles

Page 688 of 2109

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

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 2K+ Views

The Hashtable class in C# represents a collection of key-value pairs organized based on the hash code of each key. In hashtables, keys are unique and non-null, while values can be null or duplicated. Often, you need to verify whether a specific key exists before performing operations like retrieval or updates. C# provides two methods to check if a key exists in a hashtable: ContainsKey() and Contains(). Both methods serve the same purpose but have slightly different naming conventions for clarity. Syntax Following is the syntax for the ContainsKey() method − public virtual bool ContainsKey(object ...

Read More

How to Create a HashTable Collection in C#?

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 305 Views

The Hashtable is a non-generic collection in C# that stores key-value pairs, similar to a generic Dictionary collection. Hashtable is defined in the System.Collections namespace and computes hash codes for keys to optimize lookups by storing them in different internal buckets. In this tutorial, we will see how to create a Hashtable collection in C# using different approaches. Key Features of Hashtable Stores key-value pairs as DictionaryEntry objects Keys must be unique and non-null, but values can be null or duplicate Keys are immutable objects that provide hash functions Values can be accessed using keys in ...

Read More

How to get keys from a HashTable in C#?

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 546 Views

The Hashtable is a non-generic collection in C# that stores key-value pairs, similar to the generic Dictionary collection. It is defined in the System.Collections namespace. A Hashtable consists of key/value pairs where each key is computed as a hash code and stored in different buckets internally. When accessing the Hashtable, this hash code is matched to locate the corresponding value, which optimizes lookup performance. Let's explore how to retrieve keys from a Hashtable in C#. Syntax Following is the syntax for accessing Hashtable keys using a foreach loop − foreach(DictionaryEntry entry in hashtable) { ...

Read More

How to Delete Item from Hashtable Collection in C#?

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 602 Views

The Hashtable in C# is a collection of key-value pairs that are organized based on the hash code of the key. Items in the hashtable are accessed using a key, and the Hashtable class provides various methods to perform operations like adding, removing, and checking for the existence of specified keys. In this article, we will discuss how to delete an item from the hashtable collection using a specified key with the Remove() method. Syntax The Hashtable class provides the Remove() method to delete an item from the hashtable collection − public virtual void Remove(object ...

Read More

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

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 2K+ Views

The Hashtable collection in C# is a collection of key-value pairs organized based on the hash code of the key. Each element is a key-value pair with unique keys, and keys cannot be null. Values can be null and duplicated. In this article, we will explore different methods to check if a Hashtable collection is empty or not. Syntax Following is the syntax for checking if a Hashtable is empty using the Count property − if (hashtable.Count == 0) { // Hashtable is empty } The Count property returns an ...

Read More

C# Program to Check if Value exists in Hashtable

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 2K+ 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 ...

Read More

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

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 1K+ Views

A hashtable is a collection in C# that holds items identified as key-value pairs. Unlike other data structures like the stack, queue, or ArrayList that store a single value, a hashtable stores two values that form an element − the key and the value. In a hashtable, the keys are unique and cannot be null. The values can be null and duplicated. The System.Collections namespace provides the Hashtable class with various constructors, methods, and properties to perform operations on hashtable objects. This article demonstrates how to retrieve a key from a hashtable collection based on a specific value. ...

Read More

C# Program to Print the Length of the Hashtable

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 895 Views

A Hashtable in C# is a collection that stores key-value pairs, where each key is unique and used to access its corresponding value. Unlike arrays or lists, Hashtables don't have a direct Length property, but we can determine the number of elements using the Count property. The Hashtable class belongs to the System.Collections namespace and organizes elements based on the hash code of their keys. Keys must be unique and non-null, while values can be duplicated or null. Syntax The Count property returns the number of key-value pairs in the Hashtable − public virtual int ...

Read More

How to Convert Hashtable into an Array?

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 2K+ Views

The Hashtable collection in C# is a non-generic collection of key-value pairs where each key is unique and non-null, while values can be duplicated or null. Converting a Hashtable into an array is a common operation when you need to work with the data in array format. The Hashtable class provides the CopyTo method to efficiently transfer its elements to an array. This method copies Hashtable items as DictionaryEntry objects to a one-dimensional array. Syntax Following is the syntax for the CopyTo method − public virtual void CopyTo(Array array, int arrayIndex); Parameters ...

Read More

Char.IsDigit() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 2K+ Views

The Char.IsDigit() method in C# determines whether a specified Unicode character is categorized as a decimal digit. This method is useful for validating input, parsing strings, and filtering numeric characters from text. Syntax Following is the syntax for the Char.IsDigit() method − public static bool IsDigit(char ch); Parameters ch − The Unicode character to evaluate. Return Value Returns true if the character is a decimal digit; otherwise, false. Using Char.IsDigit() with Different Characters Example 1 - Testing Non-Digit Characters using System; public ...

Read More
Showing 6871–6880 of 21,090 articles
« Prev 1 686 687 688 689 690 2109 Next »
Advertisements