একটি লিঙ্কডলিস্ট সেট করুন এবং উপাদান যোগ করুন৷
৷string [] students = {"Beth","Jennifer","Amy","Vera"};
LinkedList<string> list = new LinkedList<string>(students); প্রথমে, শেষে একটি নতুন নোড যোগ করুন৷
৷var newNode = list.AddLast("Emma"); এখন, প্রদত্ত নোডের পরে একটি নোড যোগ করতে AddAfter() পদ্ধতি ব্যবহার করুন৷
list.AddAfter(newNode, "Matt");
নিম্নলিখিত সম্পূর্ণ কোড৷
৷উদাহরণ
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
string [] students = {"Beth","Jennifer","Amy","Vera"};
LinkedList<string> list = new LinkedList<string>(students);
foreach (var stu in list) {
Console.WriteLine(stu);
}
// adding a node at the end
var newNode = list.AddLast("Emma");
// adding a new node after the node added above
list.AddAfter(newNode, "Matt");
Console.WriteLine("LinkedList after adding new nodes...");
foreach (var stu in list) {
Console.WriteLine(stu);
}
}
} আউটপুট
Beth Jennifer Amy Vera LinkedList after adding new nodes... Beth Jennifer Amy Vera Emma Matt