প্রথমত, নোড সহ একটি লিঙ্কডলিস্ট সেট করুন।
string [] students = {"Tim","Jack","Henry","David","Tom"}; LinkedList<string> list = new LinkedList<string>(students);
প্রথম অবস্থানে একটি নোড যোগ করতে, AddFirst() পদ্ধতি ব্যবহার করুন।
list.AddFirst("Amit");
উদাহরণ
using System; using System.Collections.Generic; class Demo { static void Main() { string [] students = {"Tim","Jack","Henry","David","Tom"}; LinkedList<string> list = new LinkedList<string>(students); foreach (var stu in list) { Console.WriteLine(stu); } // adding a node Console.WriteLine("LinkedList after adding a node at the first position..."); list.AddFirst("Amit"); foreach (var stu in list) { Console.WriteLine(stu); } } }
আউটপুট
Tim Jack Henry David Tom LinkedList after adding a node at the first position... Amit Tim Jack Henry David Tom