C# LinkedList AddBefore(LinkedListNode, T)

Description

LinkedList AddBefore(LinkedListNode , T) 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 LinkedListNode before 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" );

   }
}




















Home »
  C# Tutorial »
    System.Collections.Generic »




HashSet
LinkedList
LinkedListNode
List
Queue
SortedSet
Stack