Add value to Hashtable and loop through the value key pairs : Hashtable : Collections Data Structure C# Source Code


Custom Search

C# Source Code » Collections Data Structure » Hashtable »

 

Add value to Hashtable and loop through the value key pairs









    


using System;
using System.Collections;

public class HashPut {
  public static void Main( ) {
    String[] identifiers ={"A","B","C","D","E","F","G","H","I","J","K","L"}; 
    String[] types = {"1","2","3","4","5","6","7","8","9","10","11","12"}; 
    Hashtable table = new Hashtable(23);
    
    for(int i = 0; i < identifiers.Length; i++) 
      table.Add(identifiers[i], types[i]);
    
    Console.WriteLine("The value of F is {0}",table["F"]);
    Console.WriteLine("The keys are:");
    
    foreach (DictionaryEntry entry in table) 
      Console.Write("{0} ", entry.Key);
   }
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Collections Data Structure
» Hashtable