
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
LinkedList RemoveLast() Method in C#
Firstly, declare a LinkedList and add nodes.
int [] num = {92, 98, 110, 130, 145, 170, 230, 240, 250, 300, 330}; LinkedList<int> myList = new LinkedList<int>(num);
Remove the last node from the LinkedList using the RemoveLast() method.
myList.RemoveLast();
Example
using System; using System.Collections.Generic; class Demo { static void Main() { int [] num = {92, 98, 110, 130, 145, 170, 230, 240, 250, 300, 330}; LinkedList<int> myList = new LinkedList<int>(num); foreach (var n in myList) { Console.WriteLine(n); } // removing last node myList.RemoveLast(); Console.WriteLine("LinkedList after removing the last node..."); foreach (var n in myList) { Console.WriteLine(n); } } }
Output
92 98 110 130 145 170 230 240 250 300 330 LinkedList after removing the last node... 92 98 110 130 145 170 230 240 250 300
- Related Articles
- LinkedList AddFirst method in C#
- LinkedList AddAfter method in C#
- LinkedList Remove method in C#
- LinkedList RemoveFirst() Method in C#
- LinkedList Clear() Method in C#
- LinkedList Contains Method in C#
- LinkedList AddLast method in C#
- LinkedList AddBefore method in C#
- What does the method removeLast() do in java?
- LinkedList in C#
- How to use removeLast() in android ConcurrentLinkedDeque?
- How to use removeLast() in android LinkedBlockingDeque?
- Removing all nodes from LinkedList in C#
- Singly LinkedList Traversal using C#
- Copy the entire LinkedList to Array in C#

Advertisements