static void Main(string[] args) { CustomLinkedList linkedList = new CustomLinkedList(); //adding items linkedList.AddLast(2); linkedList.AddLast(3); linkedList.AddLast(4); linkedList.AddLast(5); linkedList.AddFirst(1); //removing items Console.WriteLine($"removed first: {linkedList.RemoveFirst()}"); Console.WriteLine($"removed last: {linkedList.RemoveLast()}"); //printing items with foreach linkedList.ForEach(item => { Console.WriteLine(item); }); //linkedlist items to array int[] arr = linkedList.ToArray(); Console.WriteLine("LinkedListToarray:"); Console.WriteLine(string.Join(" ", arr)); }
static void Main() { CustomLinkedList <string> test = new CustomLinkedList <string>(); test.Add(new CustomLinkedList <string> .Node <string>("a")); test.Add(new CustomLinkedList <string> .Node <string>("s")); test.Add(new CustomLinkedList <string> .Node <string>("d")); test.Add(new CustomLinkedList <string> .Node <string>("f")); test.Add(new CustomLinkedList <string> .Node <string>("g")); foreach (var i in test) { Console.WriteLine(i); } }