The Values property gets an ICollection containing the values in the Hashtable.
Declare Hashtable collection −
Hashtable ht = new Hashtable();
Now add values
ht.Add("One", "Henry");
ht.Add("Two", "Kevin");
ht.Add("Three", "David");To display values from Hashtable, the following is the code −
Example
using System;
using System.Collections;
namespace Demo {
class Program {
static void Main(string[] args) {
Hashtable ht = new Hashtable();
ht.Add("One", "Henry");
ht.Add("Two", "Kevin");
ht.Add("Three", "David");
// Displaying values
foreach (string value in ht.Values) {
Console.WriteLine(value);
}
Console.ReadKey();
}
}
}Output
David Henry Kevin