We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Saturday, June 27, 2015

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: