Create StringDictionary and hashtable with some data and Display both StringDictionary and hashtable data in sorted order. Display differentiation between StringDictionary and hashtable using your own methods.
class Program
{
static void Main()
{
Program ObjPro = new Program();
ObjPro.StrDic();
Console.WriteLine();
ObjPro.HashTab();
Console.ReadLine();
}
public void StrDic()
{
StringDictionary ObjSD = new StringDictionary();
ObjSD.Add("First", "Mithilesh");
ObjSD.Add("Second", "Rakesh");
ObjSD.Add("Third", "Mohan");
ObjSD.Add("Forth", "Juliya");
ObjSD.Add("Fifth", "Tina");
foreach (DictionaryEntry Items in ObjSD)
{
Console.WriteLine("{0}:-{1}", Items.Key, Items.Value);
}
}
public void HashTab()
{
Hashtable Objhash = new Hashtable();
Objhash.Add(1, "Computer");
Objhash.Add(2, "Mobile");
Objhash.Add(3, "Speaker");
Objhash.Add(4, "Laptop");
foreach (DictionaryEntry Items in Objhash)
{
Console.WriteLine("{0}:-{1}", Items.Key, Items.Value);
}
}
}
output:
No comments:
Post a Comment