নিম্নলিখিত আমাদের লিঙ্কডলিস্ট.
string [] employees = {"Patrick","Robert","John","Jacob", "Jamie"}; LinkedList<string> list = new LinkedList<string>(employees);
এখন, ধরা যাক আপনাকে শেষ নোড অর্থাৎ "Jamie" অপসারণ করতে হবে। এর জন্য, RemoveLast() পদ্ধতি ব্যবহার করুন।
list.RemoveLast();
উদাহরণ
using System; using System.Collections.Generic; class Demo { static void Main() { string [] employees = {"Patrick","Robert","John","Jacob", "Jamie"}; LinkedList<string> list = new LinkedList<string>(employees); foreach (var emp in list) { Console.WriteLine(emp); } // removing last node list.RemoveLast(); Console.WriteLine("LinkedList after removing last node..."); foreach (var emp in list) { Console.WriteLine(emp); } } }
আউটপুট
Patrick Robert John Jacob Jamie LinkedList after removing last node... Patrick Robert John Jacob