Get the next node in the LinkedList in CSharp

Description

The following code shows how to get the next node in the LinkedList.

Example


using System;/*from   w  ww .  j  ava 2  s . c o  m*/
using System.Collections.Generic;

public class GenericCollection  {

   public static void Main()  {
      LinkedListNode<String> lln = new LinkedListNode<String>( "Java" );
      DisplayProperties( lln );
      LinkedList<String> ll = new LinkedList<String>();

      ll.AddLast( lln );
      DisplayProperties( lln );

      ll.AddFirst( "XML" );
      DisplayProperties( lln );
   }
   public static void DisplayProperties( LinkedListNode<String> lln )  {

      if ( lln.Next == null )
         Console.WriteLine("Next node is null." );
      else
         Console.WriteLine("Value of next node:     {0}", lln.Next.Value );
   }

}




















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary