Add key-value pair to Hashtable by using the indexer : Hashtable : Data Structure C# Examples


C# Examples » Data Structure » Hashtable »

 

Add key-value pair to Hashtable by using the indexer









    
using  System;  
using  System.Collections;  
  
class  HashtableDemo  {  
    public  static  void  Main()  {  
        Hashtable  ht  =  new  Hashtable();  
          
        
        ht.Add("a",  "A");  
        ht.Add("b",  "B");  
        ht.Add("c",  "C");  
        ht.Add("e",  "E");  

        
        ht["f"]  =  "F";  
  
        //  Get  a  collection  of  the  keys.  
        ICollection  c  =  ht.Keys;  
  
        foreach(string  str  in  c)  
            Console.WriteLine(str  +  ":  "  +  ht[str]);  
    }  
}
    
   
  
   



Output

a: A
b: B
c: C
e: E
f: F


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Hashtable