Articles → CSHARP → Hashtable In C#
Hashtable In C#
Key-Value Pair
Days | Places |
---|
Day 1 | Place 1 |
Day 2 | Place 2 |
Day 3 | Place 3 |
Day 4 | Place 3 |
HashTable
Syntax
Hashtable objectHashtable = new Hashtable();
Example
using System;
using System.Collections;
using System.Collections.Generic;
namespace Test1 {
class Program {
static void Main(string[] args) {
Hashtable table = new Hashtable();
table.Add("Day 1", "Place 1");
table.Add("Day 2", "Place 2");
table.Add("Day 3", "Place 3");
table.Add("Day 4", "Place 3");
Console.WriteLine("Looping");
foreach(DictionaryEntry pair in table) {
Console.WriteLine(pair.Key + "--" + pair.Value);
}
Console.ReadLine();
}
}
}
Output
Posted By - | Karan Gupta |
|
Posted On - | Wednesday, December 21, 2016 |