LinkedList की शुरुआत में किसी नोड को निकालने के लिए, 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