-
Notifications
You must be signed in to change notification settings - Fork 0
/
HashTables.cs
34 lines (24 loc) · 903 Bytes
/
HashTables.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections;
namespace Variables
{
class Program{
static void Main(string[] args)
{
Hashtable NoteBook = new Hashtable();
NoteBook.Add(1,"Nour"); //add Key and Value
NoteBook.Add(2,"Ali");
NoteBook.Add(3, "Nader");
//creating a Hashtable using collection-initializer syntax
var cities = new Hashtable(){
{"UK", "London, Manchester, Birmingham"},
{"USA", "Chicago, New York, Washington"},
{"Egypt", "Cairo, Alexandria, Luxor"}
};
foreach (DictionaryEntry item in NoteBook)
Console.WriteLine("key:{0}, value:{1}",item.Key, item.Value);
foreach (DictionaryEntry item in cities)
Console.WriteLine("Key: {0}, Value: {1}", item.Key, item.Value);
}
}
}