How to find and remove the last occurrence of a 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#", "c", "php", "nodejs", "java", "c", "c++" };
          
        LinkedList<string> ll = new LinkedList<string>(arr);
         
        LinkedListNode<string> current = ll.FindLast("c");
		
        ll.Remove(current); 
		
		PrintLinkedList(ll);
    }
}
  


/*
run:

python c# c php nodejs java c++

*/
  

 



answered May 7, 2020 by avibootz

Related questions

1 answer 118 views
1 answer 107 views
1 answer 114 views
1 answer 129 views
1 answer 122 views
...