The following is our LinkedList list with nodes.
string [] students = {"Katie","Jennifer","Amy","Vera"}; LinkedList<string> list = new LinkedList<string>(students);
Now let us remove a node with the string element “Vera”.
For that, use Remove() method.
list.Remove("Vera");
using System; using System.Collections.Generic; class Demo { static void Main() { string [] students = {"Katie","Jennifer","Amy","Vera"}; LinkedList<string> list = new LinkedList<string>(students); foreach (var stu in list) { Console.WriteLine(stu); } // removing a node list.Remove("Vera"); Console.WriteLine("LinkedList after removing a node..."); foreach (var stu in list) { Console.WriteLine(stu); } } }
Katie Jennifer Amy Vera LinkedList after removing a node... Katie Jennifer Amy