C# LinkedList AddFirst(LinkedListNode)

Description

LinkedList AddFirst(LinkedListNode ) adds the specified new node at the start of the LinkedList .

Syntax

LinkedList.AddFirst(LinkedListNode) has the following syntax.


public void AddFirst(
  LinkedListNode<T> node
)

Parameters

LinkedList.AddFirst(LinkedListNode) has the following parameters.

  • node - The new LinkedListNode to add at the start of the LinkedList .

Example


using System;// w  ww  .  j a v  a2s.com
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.AddFirst(ll.First );

   }
}




















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




HashSet
LinkedList
LinkedListNode
List
Queue
SortedSet
Stack