C# LinkedList AddBefore(LinkedListNode, T)
Description
LinkedList
adds
a new node containing the specified value before the specified existing
node in the LinkedList
Syntax
public LinkedListNode<T> AddBefore(
LinkedListNode<T> node,
T value
)
Parameters
node
- The LinkedListNodebefore which to insert a new LinkedListNode containing value. value
- The value to add to the LinkedList.
Example
using System;/*from ww w .ja v a 2s . co m*/
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,"Z" );
}
}