---
title: "how to use Hashtable in c# .net"  
description: "how to use Hashtable in c# .net"  
author: "Anonymous User"  
published: 2015-11-23  
updated: 2015-11-23  
canonical: https://www.mindstick.com/forum/33627/how-to-use-hashtable-in-c-sharp-dot-net  
category: ".net"  
tags: ["c#", "hashtable"]  
reading_time: 1 minute  

---

# how to use Hashtable in c# .net

I want to use Hashtable in [c# .net](https://www.mindstick.com/forum/159581/how-to-design-a-calculator-program-in-c-sharp-dot-net) please help me.

## \

## Replies

### Reply by Anonymous User

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 hash table is used when you need to access elements by using key, and you can identify a useful key value. Each item in the hash table has a key/value pair. The key is used to access the items in the collection.

```
using System;using System.Collections;namespace CollectionsApplication{    class Program    {        static void Main(string[] args)        {            Hashtable ht = new Hashtable();            ht.Add("001", "Aditya Kumar");            ht.Add("002", "Manoj Singh");            ht.Add("003", "Sohel safe");            ht.Add("004", "V.k Patel");            ht.Add("005", "Atul Varma");            ht.Add("006", "M. Arif");            ht.Add("007", "Ritesh Saikia");            if (ht.ContainsValue("Visal Pateker"))            {                Console.WriteLine("This employee name is already in the list");            }            else            {                ht.Add("008", "Visal Pateker");            }            // Get a collection of the keys.            ICollection key = ht.Keys;            foreach (string k in key)            {                Console.WriteLine(k + ": " + ht[k]);            }            Console.ReadKey();        }    }}
```

```

```


---

Original Source: https://www.mindstick.com/forum/33627/how-to-use-hashtable-in-c-sharp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
