C# | Gets an ICollection containing the values in the Hashtable Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Hashtable.Values Property is used to get an ICollection containing the values in the Hashtable. Syntax: public virtual System.Collections.ICollection Values { get; } Return Value: This property returns an ICollection containing the values in the Hashtable. Note: The order of values in the ICollection is unspecified. Retrieving the value of this property is an O(1) operation. Below programs illustrate the use of above-discussed property: Example 1: CSharp // C# code to get an ICollection containing // the values in the Hashtable. using System; using System.Collections; class GFG { // Driver code public static void Main() { // Creating a Hashtable Hashtable myTable = new Hashtable(); // Adding elements in Hashtable myTable.Add("g", "geeks"); myTable.Add("c", "c++"); myTable.Add("d", "data structures"); myTable.Add("q", "quiz"); // Get a collection of the values ICollection c = myTable.Values; // Displaying the contents foreach(string str in c) Console.WriteLine(str + myTable[str]); } } Output: data structures c++ quiz geeks Example 2: CSharp // C# code to get an ICollection containing // the values in the Hashtable. using System; using System.Collections; class GFG { // Driver code public static void Main() { // Creating a Hashtable Hashtable myTable = new Hashtable(); // Adding elements in Hashtable myTable.Add("India", "Country"); myTable.Add("Chandigarh", "City"); myTable.Add("Mars", "Planet"); myTable.Add("China", "Country"); // Get a collection of the values ICollection c = myTable.Values; // Displaying the contents foreach(string str in c) Console.WriteLine(str + myTable[str]); } } Output: City Country Country Planet Reference: https://learn.microsoft.com/en-us/dotnet/api/system.collections.hashtable.values?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | Get an ICollection containing the values in HybridDictionary K Kirti_Mangal Follow Improve Article Tags : C# CSharp-Collections-Hashtable CSharp-Collections-Namespace Similar Reads C# | Gets an ICollection containing the keys in the Hashtable Hashtable.Keys Property is used to get an ICollection containing the keys in the Hashtable. Syntax: public virtual System.Collections.ICollection Keys { get; } Return Value: This property returns an ICollection containing the keys in the Hashtable. Note: The order of keys in the ICollection is unspe 2 min read C# | Get an ICollection containing the values in HybridDictionary HybridDictionary.Values property is used to get an ICollection containing the values in the HybridDictionary. Syntax: public System.Collections.ICollection Values { get; } Return Value: It returns an ICollection containing the values in the HybridDictionary. Below programs illustrate the use of Hybr 2 min read C# | Get an ICollection containing the values in ListDictionary ListDictionary.Values property is used to get an ICollection containing the values in the ListDictionary. Syntax: public System.Collections.ICollection Values { get; } Return Value : It returns an ICollection containing the values in the ListDictionary. Below are the programs to illustrate the use o 2 min read C# | Get an ICollection containing values in OrderedDictionary OrderedDictionary.Values property is used to get an ICollection object containing the values in the OrderedDictionary collection. Syntax: public System.Collections.ICollection Values { get; } Return Value: It returns an ICollection object containing the values in the OrderedDictionary collection. Be 2 min read C# | Get an ICollection containing the keys in HybridDictionary HybridDictionary.Keys property is used to get an ICollection containing the keys in the HybridDictionary. Syntax: public System.Collections.ICollection Keys { get; } Return Value: It returns an ICollection containing the keys in the HybridDictionary. Below programs illustrate the use of HybridDictio 2 min read C# | Check if the Hashtable contains a specific Value The Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. The key is used to access the items in the collection. Hashtable.ContainsValue(Object) Method is used to check whether the Hashtable contains a specific value or not. Syntax: publ 2 min read Like