C# LinkedListNode Previous
Description
LinkedListNode
gets the previous node
in the LinkedList
Syntax
LinkedListNode.Previous
has the following syntax.
public LinkedListNode<T> Previous { get; }
Example
using System;/*from ww w . j a va2 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" );
ll.AddLast( "HTML" );
DisplayProperties( lln );
}
public static void DisplayProperties( LinkedListNode<String> lln ) {
if ( lln.Previous == null )
Console.WriteLine("Previous node is null." );
else
Console.WriteLine("Value of previous node: {0}", lln.Previous.Value );
}
}
The code above generates the following result.