একটি LinkedList সাফ করতে Clear() পদ্ধতি ব্যবহার করুন। এটি লিঙ্কডলিস্ট থেকে সমস্ত নোড মুছে ফেলবে৷
৷ধরা যাক নিম্নলিখিতটি আমাদের লিঙ্কডলিস্ট -
int [] num = {30, 65, 80, 95, 110, 135};
LinkedList<int> list = new LinkedList<int>(num); লিঙ্কডলিস্ট সাফ করতে।
list.Clear();
উদাহরণ
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
int [] num = {30, 65, 80, 95, 110, 135};
LinkedList<int> list = new LinkedList<int>(num);
foreach (var n in list) {
Console.WriteLine(n);
}
// clear
list.Clear();
Console.WriteLine("No node in the LinkedList now...");
foreach (var n in list) {
Console.WriteLine(n);
}
}
} আউটপুট
30 65 80 95 110 135 No node in the LinkedList now...