Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
using System;
using System.Collections;
public class ExampleHashtable
{
public void exampleAdd()
{
Hashtable Ht = new Hashtable();
Ht.Add(01, "This");
Ht.Add(03, "is");
Ht.Add(04, "my");
Ht.Add(06, "system");
int i = 0;
foreach(var h in Ht)
{
Console.WriteLine("Ht["+ i + "] = " +Ht[i++]);
}
ICollection ic;
ic = Ht.Keys;
foreach(var k in ic)
{
Console.WriteLine(k);
}
if (Ht.ContainsKey(04))
{
Console.WriteLine("Key found");
}
else
{
Console.WriteLine("Key not found");
}
if (Ht.ContainsValue("my"))
{
Console.WriteLine("value found");
}
else
{
Console.WriteLine("value not found");
}
}
}
namespace collectionHashtable
{
class Program
{
static void Main(string[] args)
{
ExampleHashtable ht = new ExampleHashtable();
ht.exampleAdd();
Console.WriteLine("It Works");
}
}
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more