Esempio n. 1
0
        protected void Button8_Click(object sender, EventArgs e)
        {
            try
            {
                ArrayListDemo a = new ArrayListDemo();

                this.TextBox1.Text += string.Format($"\r\n{a.ArrayListTest()}");
            }
            catch (Exception ex)
            {
                this.TextBox1.Text += string.Format($"\r\nError occurred {ex.Message }");
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("-- ArrayList --");
            ArrayListDemo AlDemo = new ArrayListDemo();

            AlDemo.AddNew();
            AlDemo.Display();
            AlDemo.Sort();
            Console.WriteLine("Sorted List.");
            AlDemo.Display();

            Console.WriteLine("-- Stack --");
            StackDemo st = new StackDemo();

            QueueDemo Q = new QueueDemo();

            Console.WriteLine("-- Generic List --");
            MyGeneric <string> gen = new MyGeneric <string>();

            gen.AddItem("abc");
            gen.AddItem("xyz");
            Console.WriteLine(gen.GetItem());
            Console.WriteLine(gen.GetItem(1));

            Console.WriteLine("-- Exceptions --");
            //UserDefinedException uexp = new UserDefinedException();
            try
            {
                UserDefinedException.ThrowUserDefinedException();
            }
            catch (UserDefinedException ex)
            {
                Console.WriteLine("Exception : " + ex.Message);
            }
            try
            {
                UserDefinedException.ThrowUserDefinedException("New Message");
            }
            catch (UserDefinedException ex)
            {
                Console.WriteLine("Exception : " + ex.Message);
            }

            Console.WriteLine("\n-- Format Deemo --");
            FormattingDemo.Display();

            DisplayXMLContents();


            MyList list = new MyList();

            Console.WriteLine(list.ToString());

            Console.WriteLine("-- AbstractClass static methos--");
            Console.WriteLine(AbstractClass.Display("Hello"));

            Console.WriteLine("-- Yield Example --");
            foreach (int i in YieldExample.Power(2, 8))
            {
                Console.Write("{0} ", i);
            }

            //// Single Thread Example.
            Console.WriteLine("\n\nSingle Thread Example.\n");
            ThreadDemo thread1 = new ThreadDemo();
            ThreadDemo thread2 = new ThreadDemo("FromMain");

            Console.WriteLine("Single Thread Ended");

            //// Single Thread Example.
            Console.WriteLine("\n\nTwo Threads Example.\n");
            TwoThreads twoThreads = new TwoThreads("Child#1", "Child#2");

            Console.WriteLine("Two Threads Ended");
            Console.ReadKey();
        }