How to use Hashtable in C#

1 Answer

0 votes
using System;
using System.Collections; 
                      
public class Program
{
    public static void Main()
    {
 		Hashtable ht = new Hashtable(); 
  
        ht.Add("c", "c#"); 
        ht.Add("a", "c++"); 
        ht.Add("d", "java"); 
        ht.Add("b", "php"); 
  
        ICollection ic = ht.Keys; 
  
        foreach(string s in ic) {
            Console.WriteLine(s + ": " + ht[s]); 
    	} 
    }
}
  

  
/*
run:
  
a: c++
b: php
c: c#
d: java
  
*/

 



answered May 10, 2020 by avibootz

Related questions

5 answers 369 views
369 views asked Sep 11, 2019 by avibootz
1 answer 207 views
1 answer 109 views
109 views asked Apr 28, 2024 by avibootz
...