C# LinkedList AddBefore(LinkedListNode, LinkedListNode)
Description
LinkedList
adds the specified new node before the specified
existing node in the LinkedList
Syntax
public void AddBefore(
LinkedListNode<T> node,
LinkedListNode<T> newNode
)
Parameters
node
- The LinkedListNodebefore which to insert newNode. newNode
- The new LinkedListNodeto add to the LinkedList .
Example
/*w w w . ja va 2 s . c o m*/
using System;
using System.Collections;
using System.Collections.Generic;
public class GenericCollection
{
public static void Main()
{
LinkedList<String> ll = new LinkedList<String>();
ll.AddLast( "A" );
ll.AddLast( "B" );
ll.AddLast( "C" );
ll.AddLast( "java2s.com" );
ll.AddBefore(ll.First,ll.Last );
}
}