Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Web Hosting

Bonsai Boy of New York Bonsai Trees and Accessories

BlueHost Web Hosting

Liquid Web iThemes WordPress Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting


getResponse autofunnels

Liquid Web Cloud VPS Hosting

11,144 questions

15,208 answers

573 users

How to use hash table (HashTable) in C#

5 Answers

0 votes
using System;
using System.Collections;
 
class Program
{
    static void Main() {
        Hashtable ht = new Hashtable();
        
        ht.Add("1", "c#");
        ht.Add("2", "c");
        ht.Add("3", "php");
        ht.Add("4", "java");
        ht.Add("5", "python");

        foreach (DictionaryEntry item in ht) {
                Console.WriteLine(item.Key + " - " + item.Value);
        }
    }
}

 
 
/*
run:
 
2 - c
3 - php
5 - python
1 - c#
4 - java
 
*/

 




answered Sep 11 by avibootz
edited Sep 12 by avibootz
0 votes
using System;
using System.Collections;
 
class Program
{
    static void Main() {
        Hashtable ht = new Hashtable();
        
        ht.Add("1", "c#");
        ht.Add("2", "c");
        ht.Add("3", "php");
        ht.Add("4", "java");
        ht.Add("5", "python");

        Console.WriteLine(ht["4"].ToString());
    }
}

 
 
/*
run:
 
java
 
*/

 




answered Sep 11 by avibootz
0 votes
using System;
using System.Collections;
 
class Program
{
    static void Main() {
        Hashtable ht = new Hashtable();
        
        ht.Add("1", "c#");
        ht.Add("2", "c");
        ht.Add("3", "php");
        ht.Add("4", "java");
        ht.Add("5", "python");

        foreach (DictionaryEntry item in ht ) {
                Console.WriteLine(item.Key + " - " + item.Value);
        }
        
        Console.WriteLine('\n');
        
        ht.Remove("3");
        
        foreach (DictionaryEntry item in ht ) {
                Console.WriteLine(item.Key + " - " + item.Value);
        }
    }
}

 
 
/*
run:
 
2 - c
3 - php
5 - python
1 - c#
4 - java


2 - c
5 - python
1 - c#
4 - java
 
*/

 




answered Sep 11 by avibootz
0 votes
using System;
using System.Collections;
 
class Program
{
    static void Main() {
        Hashtable ht = new Hashtable();
        
        ht.Add(1, "c#");
        ht.Add(2, "c");
        ht.Add(3, "php");
        ht.Add(4, "java");
        ht.Add(5, "python");

        foreach (DictionaryEntry item in ht ) {
                Console.WriteLine(item.Key + " - " + item.Value);
        }
    }
}

 
 
/*
run:
 
5 - python
4 - java
3 - php
2 - c
1 - c#
 
*/

 




answered Sep 11 by avibootz
0 votes
using System;
using System.Collections;
  
class Program
{
    static void Main() {
        Hashtable ht = new Hashtable();
         
        ht.Add(1, "c#");
        ht.Add(2, "c");
        ht.Add(3, "php");
        ht.Add(4, "java");
        ht.Add(5, "python");
 
        if (ht.ContainsValue("java")) {
            Console.WriteLine("yes");
        }
    }
}
 
  
  
/*
run:
  
yes
  
*/

 




answered Sep 11 by avibootz
...