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