C# LinkedListNode List

Description

LinkedListNode List gets the LinkedList that the LinkedListNode belongs to.

Syntax

LinkedListNode.List has the following syntax.


public LinkedList<T> List { get; }

Example


using System;//ww w.ja  v  a2  s  .com
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" );
      ll.AddLast( "HTML" );
      DisplayProperties( lln );
   }
   public static void DisplayProperties( LinkedListNode<String> lln )  {
      if ( lln.List == null )
         Console.WriteLine("Node is not linked." );
      else
         Console.WriteLine("Node belongs to a linked list with {0} elements.", lln.List.Count );

   }

}

The code above generates the following result.





















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




HashSet
LinkedList
LinkedListNode
List
Queue
SortedSet
Stack