- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Program to add a node at the last position in a Linked List
Set a LinkedList with nodes.
string [] students = {"Tim","Jack","Henry","David","Tom"}; LinkedList<string> list = new LinkedList<string>(students);
Now, use the AddLast() method to add a node at the last position.
list.AddLast("Kevin");
Here is the complete code with the updated LinkedList.
Example
using System; using System.Collections.Generic; class Demo { static void Main() { string [] students = {"Tim","Jack","Henry","David","Tom"}; LinkedList<string> list = new LinkedList<string>(students); foreach (var stu in list) { Console.WriteLine(stu); } // adding a node at the end Console.WriteLine("LinkedList after adding a node at the last position..."); list.AddLast("Kevin"); foreach (var stu in list) { Console.WriteLine(stu); } } }
Output
Tim Jack Henry David Tom LinkedList after adding a node at the last position... Tim Jack Henry David Tom Kevin
- Related Articles
- C# Program to add a node at the first position in a Linked List
- Java Program to Add Element at First and Last Position of a Linked list
- Golang program to insert a node at the ith index node, when the index is at the last position in the linked list.
- C program to insert a node at any position using double linked list
- Delete a Linked List node at a given position in C++
- C# Program to add a node after the given node in a Linked List
- C# Program to add a node before the given node in a Linked List
- Delete a Doubly Linked List node at a given position in C++
- Golang Program to add a node at the end of a given linked list.
- Golang Program to delete the last node from a linked list.
- Golang Program to update the last node value in a linked list.
- C# Program to remove a node at the beginning of a Linked List
- Golang Program to insert a node at the ith index node, when the index is at the 0th position in the linked list.
- Golang Program to add the first node in a given linked list.
- C# Program to remove a node at the end of the Linked List

Advertisements