প্রথমত, একটি লিঙ্কডলিস্ট ঘোষণা করুন এবং নোড যোগ করুন।
int [] num = {92, 98, 110, 130, 145, 170, 230, 240, 250, 300, 330};
LinkedList<int> myList = new LinkedList<int>(num); RemoveLast() পদ্ধতি ব্যবহার করে LinkedList থেকে শেষ নোডটি সরান।
myList.RemoveLast();
উদাহরণ
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);
}
}
} আউটপুট
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