예제 #1
0
        static void Main(string[] args)
        {
            CustomLinkedList myList = new CustomLinkedList();

            myList.Add("Data 1");
            myList.Add("Data 2");
            myList.Add("Data 3");
            myList.Add("Data 4");
            myList.Add("Data 5");

            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine(myList.GetData(i));
            }

            Console.WriteLine();

            Console.WriteLine("The value at index 1 (position 2) is " + myList.GetData(1));

            Console.ReadKey();
        }
예제 #2
0
파일: Program.cs 프로젝트: evad1n/GDAPS2
        static void Main(string[] args)
        {
            Console.WriteLine("The original list values: ");
            CustomLinkedList <int> list = new CustomLinkedList <int>();

            list.Add(1);
            list.Add(3);
            list.Add(6);
            list.Add(72);
            list.Add(123123);
            list.Add(322);

            for (int i = 0; i < list.count; i++)
            {
                Console.WriteLine(list.GetData(i));
            }

            Console.WriteLine("\nAttempting to remove an invalid index: ");
            try
            {
                Console.WriteLine(list.Remove(10));
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("\nRemoved list values: ");
            Console.WriteLine(list.Remove(0));
            Console.WriteLine(list.Remove(list.count - 1));
            Console.WriteLine(list.Remove(2));

            Console.WriteLine("\nThe changed list values: ");
            for (int i = 0; i < list.count; i++)
            {
                Console.WriteLine(list.GetData(i));
            }
        }