How to move the first node to be last node in LinkedList with C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
                      
public class Program
{
    private static void PrintLinkedList(LinkedList<string> ll) {
        foreach (string word in ll) {
            Console.Write(word + " ");
        }
        Console.WriteLine();
    }
    public static void Main()
    {
        string[] arr =  { "python", "c#", "php", "nodejs", "java", "c" };
          
        LinkedList<string> ll = new LinkedList<string>(arr);
		
        ll.AddLast(ll.First.Value);
		ll.RemoveFirst();
          
        PrintLinkedList(ll);
    }
}
  


/*
run:

c# php nodejs java c python

*/
  

 



answered May 7, 2020 by avibootz

Related questions

1 answer 154 views
1 answer 135 views
1 answer 141 views
1 answer 130 views
1 answer 153 views
...