Beispiel #1
0
        static void Main(string[] args)
        {
            MyLinkedList <int> list;

            list = new MyLinkedList <int>();
            EventHandler <int> eventHandlerA = (sender, item) => Console.WriteLine("New item is added");
            EventHandler <int> eventHandlerR = (sender, item) => Console.WriteLine("Item is removed");
            EventHandler       eventHandlerC = (sender, item) => Console.WriteLine("List was cleared");

            list.Added   += eventHandlerA;
            list.Removed += eventHandlerR;
            list.Cleared += eventHandlerC;
            list.Add(3);
            list.Add(5);
            list.Add(6);
            Console.WriteLine(list.Count().ToString());
            //list.Remove(6);
            //list.Remove(3);
            //list.Remove(5);
            Console.WriteLine(list.Count().ToString());
            Console.WriteLine(list.Contains(6).ToString());

            int[] array = new int[2];
            list.CopyTo(array, 1);
            foreach (int i in array)
            {
                Console.WriteLine(i.ToString());
            }
            list.Insert(2, 5);
            list.Insert(1, 3);
            array = new int[3];
            list.CopyTo(array, 0);
            foreach (int i in array)
            {
                Console.WriteLine(i.ToString());
            }
            Console.ReadKey();
        }