This documentation is archived and is not being maintained.

LinkedList.RemoveLast Method

Removes the node at the end of the LinkedList.

Namespace: System.Collections.Generic
Assembly: System (in system.dll)

public void RemoveLast ()
public void RemoveLast ()
public function RemoveLast ()
Not applicable.

Exception typeCondition


The LinkedList is empty.

This method is an O(1) operation.

The following code example and output demonstrate the RemoveLast method. The code example uses the RemoveLast method to remove the last node in a linked list of strings, then adds a new node to the end of the list, marks that node, removes it, and inserts it at the beginning of the list.

This code and output are part of a larger example provided for the LinkedList class.

// Move the last node to be the first node.
mark1 = sentence.Last;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0