LinkedListlist = new LinkedList (); LinkedListNode node = list.AddFirst(1); list.AddAfter(node, 2); list.AddAfter(node.Next, 3); // node.Next is the second node in the list
LinkedListIn this example, we create a new linked list and add three nodes to it. We then remove the first node from the list, using the LinkedList.Remove method. Both of these examples are part of the .NET Framework's System.Collections.Generic package library, which provides generic collection classes.list = new LinkedList (); LinkedListNode node = list.AddLast(1); list.AddLast(2); list.AddLast(3); list.Remove(node); // remove the first node in the list