প্রথমত, একটি তালিকা সেট করুন -
List<int> myList = new List<int>(); myList.Add(45); myList.Add(77);
এখন, উপরের তালিকাটি পরিষ্কার করতে, Clear() -
ব্যবহার করুনmyList.Clear();
এখানে সম্পূর্ণ কোড −
উদাহরণ
using System;
using System.Collections.Generic;
public class Demo {
public static void Main() {
List<int> myList = new List<int>();
myList.Add(45);
myList.Add(77);
Console.WriteLine("Elements: "+myList.Count);
myList.Clear();
Console.WriteLine("Elements after using clear: "+myList.Count);
}
} আউটপুট
Elements: 2 Elements after using clear: 0