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);
}
// पहला नोड हटाना
list.RemoveFirst();
Console.WriteLine("पहला नोड हटाने के बाद LinkedList...");
foreach (var emp in list) {
Console.WriteLine(emp);
}
}
}
आउटपुट
Peter Robert John Jacob पहला नोड हटाने के बाद LinkedList... Robert John Jacob