예제 #1
0
        static void Main(string[] args)
        {
            //Example with list of ints
            var intList = new GenericList <int>();

            for (int i = 0; i < 10; i++)
            {
                intList.AddHead(i);
            }

            foreach (var item in intList)
            {
                Console.Write(item + " ");                      //Output: 9 8 7 6 5 4 3 2 1 0
            }

            Console.WriteLine("\n"); //Spacer

            //Example with list of strings
            var stringList = new GenericList <string>();

            for (int i = 0; i < 10; i++)
            {
                stringList.AddHead("Bill");
            }

            foreach (var item in stringList)
            {
                Console.Write(item + " ");                      //Output: Bill Bill Bill Bill Bill Bill Bill Bill Bill Bill
            }

            Console.WriteLine("\n"); //Spacer
        }
예제 #2
0
        static void Main(string[] args)
        {
            // int is the type argument
            GenericList <int> list = new GenericList <int>();

            for (int x = 0; x < 10; x++)
            {
                list.AddHead(x);
            }

            // Will Not Compile
            //list.AddHead("omer");

            foreach (int i in list)
            {
                System.Console.Write(i + " ");
            }

            System.Console.WriteLine("\nDone");

            SMS <string, DateTime> sms1 = new SMS <string, DateTime>();

            sms1.Subject = "Hi";
            sms1.Message = DateTime.Now;
            sms1.Send("052-9856987");
        }
예제 #3
0
        static void Main(string[] args)
        {
            //Create generic class with int
            GenericList <int> listInt = new GenericList <int>();

            listInt.AddHead(1);
            listInt.AddHead(2);
            listInt.AddHead(3);
            listInt.AddHead(4);

            System.Console.Write("Stack of integer: ");
            foreach (int i in listInt)
            {
                System.Console.Write(i + " ");
            }

            System.Console.WriteLine("\n");


            //Create generic class with String

            GenericList <string> listString = new GenericList <string>();

            listString.AddHead("A");
            listString.AddHead("B");
            listString.AddHead("C");
            listString.AddHead("D");

            System.Console.Write("Stack of string: ");
            foreach (string i in listString)
            {
                System.Console.Write(i + " ");
            }


            System.Console.WriteLine("\n\nDone.");
            Console.ReadKey();
        }
예제 #4
0
        public static void Main()
        {
            // int is the type argument
            GenericList <int> list = new GenericList <int>();

            for (int x = 0; x < 10; x++)
            {
                list.AddHead(x);
            }

            foreach (int i in list)
            {
                System.Console.Write(i + " ");
            }
            System.Console.WriteLine("\nDone");

            // Declare a list of type string
            GenericList <string> list2 = new GenericList <string>();

            // Declare a list of type ExampleClass
            GenericList <DelegateTestExampleClass> list3 = new GenericList <DelegateTestExampleClass>();

            Node4 <string> n4 = new Node4 <string>("hello ", 4);
            Node5 <Node4 <string>, Node5 <int, int> > n5 =
                new Node5 <Node4 <string>, Node5 <int, int> >(
                    new Node4 <string>("hello", 5), new Node5 <int, int>(6, 7));

            NodeItem <DelegateTestExampleClass> strNode = new NodeItem <DelegateTestExampleClass>();

            SwapTest();

            List <int> intList1 = new List <int>();

            AddToList1(intList1);

            DelegateTest();
            DefaultTest();
            OutTest();
        }