19 October 2011

Hash table in C#

Hash table in C#

// statements_foreach_hashtable.cs
// Using the Hashtable collection class
using System;
using System.Collections;
public class MainClass 
{
   public static void Main(string [] args) 
   {
      // Declare a Hashtable object:
      Hashtable ziphash = new Hashtable();

      // Add entries using the Add() method:
      ziphash.Add("98008", "Bellevue");
      ziphash.Add("98052", "Redmond");
      ziphash.Add("98201", "Everett");
      ziphash.Add("98101", "Seattle");
      ziphash.Add("98371", "Puyallup");

      // Display contents:
      Console.WriteLine("Zip code       City");
      foreach (string zip in ziphash.Keys) 
      {
         Console.WriteLine(zip + "          " + ziphash[zip]);
      }
   }
}

Output

Zip code       City
98201          Everett
98052          Redmond
98101          Seattle
98008          Bellevue
98371          Puyallup


No comments:

Post a Comment

Comments Welcome

Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...