Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            MyArrayList arrayList = new MyArrayList(new Object[] { 10, 20, "string" });

            arrayList.Add("New Object");
            Console.WriteLine(arrayList[3]);
            foreach (var VARIABLE in arrayList)
            {
                Console.WriteLine(VARIABLE);
            }

            arrayList.Remove(1);
            foreach (var VARIABLE in arrayList)
            {
                Console.WriteLine(VARIABLE);
            }

            Console.WriteLine(arrayList.Length);
            arrayList.Insert(2, "New Value in 3rd position");
            foreach (var VARIABLE in arrayList)
            {
                Console.WriteLine(VARIABLE);
            }
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public object Clone()
        {
            var array = new MyArrayList();

            foreach (var item in this.array)
            {
                array.Add(item);
            }

            return(array);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            MyArrayList data = new MyArrayList(100);

            data.Add(20);
            data.Add(40);
            data.Add(30);
            data.Add(4);
            data.Add(15);
            data.Add(5);
            data.Add(25);
            Console.WriteLine("Size of array: {0}", data.Count);
            Console.WriteLine("Array before sort!");
            data.Display();
            data.BubbleSort();
            Console.WriteLine("Array after sort!");
            Console.WriteLine("Size of array: {0}", data.Count);
            data.Display();
            Console.WriteLine("Array after Add first!");
            data.AddFirst(100);
            data.Display();
            Console.WriteLine("Size of array: {0}", data.Count);
            Console.WriteLine("Array after Add item to index of 2!");
            data.Add(2, 1000);
            data.Display();

            //check is contain 4
            long searchKey = 4;

            if (data.Contains(searchKey))
            {
                Console.WriteLine("Array contain {0} !", searchKey);
            }
            else
            {
                Console.WriteLine("Array does not contain {0}", searchKey);
            }

            data.Reverse();
            Console.WriteLine("Array after Reverse!");
            data.Display();

            data.Clear();
            Console.WriteLine("Size of array after reset: {0}", data.Count);
            Console.ReadLine();
        }