Get an ICollection containing the values in the Hashtable in CSharp

Description

The following code shows how to get an ICollection containing the values in the Hashtable.

Example


using System;//w ww .jav  a 2 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.Values)
        {
            Console.WriteLine(firstName);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary