How to remove element from Hashtable by key 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("e", "c");         
		ht.Add("b", "php"); 
		
		ht.Remove("d"); 
  
        foreach(DictionaryEntry de in ht) { 
            Console.WriteLine("{0}: {1} ", de.Key, de.Value); 
        } 
    }
}
  

  
/*
run:
  
a: c++ 
b: php 
c: c# 
e: c
  
*/

 



answered May 10, 2020 by avibootz

Related questions

1 answer 165 views
1 answer 162 views
162 views asked Feb 20, 2017 by avibootz
1 answer 168 views
2 answers 225 views
1 answer 169 views
1 answer 131 views
1 answer 147 views
...