LinkedList AddLast method in C#



Declare a string array.

string [] students = {"Jenifer","Angelina","Vera"};

Add it to a LinkedList.

string [] students = {"Jenifer","Angelina","Vera"};

Now, use AddLast() method to add a node at the end.

list.AddLast("Anne");

Example

 Live Demo

using System; using System.Collections.Generic; class Demo {    static void Main() {       string [] students = {"Jenifer","Angelina","Vera"};       LinkedList<string> list = new LinkedList<string>(students);       foreach (var stu in list) {          Console.WriteLine(stu);       }       // add a node at the end       Console.WriteLine("Node added at the last...");       list.AddLast("Anne");       foreach (var stu in list) {          Console.WriteLine(stu);       }    } }

Output

Jenifer Angelina Vera Node added at the last... Jenifer Angelina Vera Anne
Updated on: 2020-06-23T08:29:12+05:30

416 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements