লিঙ্কডলিস্ট থেকে নির্দিষ্ট নোডটি সরাতে, কোডটি নিম্নরূপ -
উদাহরণ
using System; using System.Collections.Generic; public class Demo { public static void Main() { LinkedList<int> list = new LinkedList<int>(); list.AddLast(100); list.AddLast(200); list.AddLast(300); list.AddLast(400); list.AddLast(500); list.AddLast(300); list.AddLast(500); Console.WriteLine("LinkedList elements..."); foreach(int i in list) { Console.WriteLine(i); } LinkedListNode<int> val = list.FindLast(300); Console.WriteLine("Specified value = "+val.Value); list.Remove(500); Console.WriteLine("LinkedList elements...UPDATED"); foreach(int i in list) { Console.WriteLine(i); } } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেLinkedList elements... 100 200 300 400 500 300 500 Specified value = 300 LinkedList elements...UPDATED 100 200 300 400 300 500
উদাহরণ
আসুন আরেকটি উদাহরণ দেখি -
using System; using System.Collections.Generic; public class Demo { public static void Main() { LinkedList<string> list = new LinkedList<string>(); list.AddLast("Mark"); list.AddLast("David"); list.AddLast("Harry"); list.AddLast("John"); list.AddLast("Kevin"); string[] strArr = new string[5]; list.CopyTo(strArr, 0); Console.WriteLine("LinkedList elements...after copying to array"); foreach(string str in strArr) { Console.WriteLine(str); } list.Remove("Harry"); Console.WriteLine("LinkedList elements...UPDATED"); foreach(string str in list) { Console.WriteLine(str); } } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেLinkedList elements...after copying to array Mark David Harry John Kevin LinkedList elements...UPDATED Mark David John Kevin