static void Main(string[] args)
        {
            // Create new GenericList
            GenericList <Point3D> points = new GenericList <Point3D>(2);

            // Test adding of elements and auto double size of list
            PrintLengthCapacity(points, "----- Test adding of elements and auto double size of list -----");
            points.Add(new Point3D(1, 2, 3));
            PrintLengthCapacity(points);
            points.Add(new Point3D());
            PrintLengthCapacity(points);
            points.Add(new Point3D(2, 4, 8));
            PrintLengthCapacity(points);
            points.Add(new Point3D(3, 5, 6));
            PrintLengthCapacity(points);

            // Access elements by index
            Console.WriteLine("----- Access elements by index -----");
            Console.WriteLine("Element[1] = {0}", points[1]);
            points[1] = new Point3D(33, 33, 33);
            PrintLengthCapacity(points, "Add new value of element[1] = " + points[1]);

            // Test find of index of given element
            Console.WriteLine("Index of element[2] = {0}", points.IndexOf(points[2]));

            // Test remove element by index
            points.RemoveAt(2);
            PrintLengthCapacity(points, "Test remove element by index");

            // Test insert element by index
            points.Insert(2, new Point3D(44, 44, 44));
            PrintLengthCapacity(points, "Test insert element by index");
            points.Insert(3, new Point3D(666, 666, 666));
            PrintLengthCapacity(points, "Test insert element by index");

            // Test Clear of list
            points.Clear();
            PrintLengthCapacity(points, "----- Test list clearing -----");
        }
Exemple #2
0
        static void Main(string[] args)
        {
            GenericList <string> list = new GenericList <string>(5);

            list.Add("232.3");
            list.Add("2.3");
            list.Add("2dwad.3");
            list.Add("2kj231332.3");
            list.Add("2.3");

            Console.WriteLine(list);
            Console.WriteLine();

            list.RemoveAtIndex(1);
            Console.WriteLine(list);
            Console.WriteLine();

            Console.WriteLine(list[3]);

            list.ClearList();
            Console.WriteLine(list);
        }
        static void Main(string[] args)
        {
            //GenericList<string> list = new GenericList<string>(5);
            //list.Add("232.3");
            //list.Add("will be removed");
            //list.Add("2dwad.3");
            //list.Add("2kj231332.3");
            //list.Add("2.3");
            //list.Add("over the initial size");
            //list.Add("over the initial size");
            //list.Add("over the initial size");


            GenericList <double> list = new GenericList <double>(5);

            list.Add(2.5);
            list.Add(2.5);
            list.Add(2.5);
            list.Add(2.5);
            list.Add(2.5);
            list.Add(2.5);
            list.Add(2.5);
            list.Add(2.5);
            list.Add(2.5);

            Console.WriteLine(list);
            Console.WriteLine();

            list.RemoveAtIndex(1);
            Console.WriteLine(list);
            Console.WriteLine();

            Console.WriteLine(list[3]);
            Console.WriteLine();

            list.ClearList();
            Console.WriteLine(list);
        }