C# Hashtable Item

Description

Hashtable Item gets or sets the value associated with the specified key.

Syntax

Hashtable.Item has the following syntax.


public virtual Object this[
  Object key
] { get; set; }

Parameters

Hashtable.Item has the following parameters.

  • key - The key whose value to get or set.

Example


using System;// ww  w .  j  a va2 s. c  o m
using System.Collections;

class MainClass
{
    public static void Main()
    {
        Hashtable    hash = new Hashtable();
        hash["A"] = "1";
        
        foreach (string firstName in hash.Keys)
        {
            Console.WriteLine("{0} {1}", firstName, hash[firstName]);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack