C# LinkedList AddAfter(LinkedListNode, LinkedListNode)

Description

LinkedList AddAfter(LinkedListNode , LinkedListNode ) adds the specified new node after the specified existing node in the LinkedList .

Syntax


public void AddAfter(
  LinkedListNode<T> node,
  LinkedListNode<T> newNode
)

Parameters

  • node - The LinkedListNode after which to insert newNode.
  • newNode - The new LinkedListNode to add to the LinkedList .

Example


/* w w  w .j  a v  a 2s.  co  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.AddAfter(ll.First,ll.Last  );

   }
}




















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




HashSet
LinkedList
LinkedListNode
List
Queue
SortedSet
Stack