示例#1
0
        static void Main(string[] args)
        {
            MyLinkedList MyList = new MyLinkedList();

            MyList.AddFirst(4);
            MyList.AddFirst(8);
            MyList.AddFirst(10);
            MyList.PrintAllNodes();

            Console.WriteLine("\t---*AddFirst*---");
            Console.Write("enter a number to insert first:");
            int num = int.Parse(Console.ReadLine());

            MyList.AddFirst(num);
            Console.WriteLine();
            MyList.PrintAllNodes();

            Console.WriteLine("\t---*AddAfter*---");
            Console.Write("enter a number that you want to insert after:");
            int AdAf = int.Parse(Console.ReadLine());

            Console.Write("\nenter a number:");
            int num1 = int.Parse(Console.ReadLine());

            MyList.AddAfter(AdAf, num1);
            Console.WriteLine();
            MyList.PrintAllNodes();

            Console.WriteLine("\t---*AddBefor*---");
            Console.Write("enter a number that you want to insert befor:");
            int AdBf = int.Parse(Console.ReadLine());

            Console.Write("\nenter a number:");
            int num2 = int.Parse(Console.ReadLine());

            MyList.AddBefor(AdBf, num2);
            Console.WriteLine();
            MyList.PrintAllNodes();

            Console.Write("enter a number to remove :");
            int rem = Convert.ToInt32(Console.ReadLine());

            MyList.DeleteNodebyKey(rem);
            Console.WriteLine();
            MyList.PrintAllNodes();

            Console.Write("enter a number to search for :");
            int search = int.Parse(Console.ReadLine());

            MyList.SearchData(search);
            Console.WriteLine();

            Console.ReadKey();
        }