সারি থেকে সমস্ত বস্তু সরাতে, কোডটি নিম্নরূপ -
উদাহরণ
using System; using System.Collections.Generic; public class Demo { public static void Main(){ Queue<string> queue = new Queue<string>(); queue.Enqueue("Gary"); queue.Enqueue("Jack"); queue.Enqueue("Ryan"); queue.Enqueue("Kevin"); queue.Enqueue("Mark"); queue.Enqueue("Jack"); queue.Enqueue("Ryan"); queue.Enqueue("Kevin"); Console.Write("Count of elements = "); Console.WriteLine(queue.Count); queue.Clear(); Console.Write("Count of elements (updated) = "); Console.WriteLine(queue.Count); } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেCount of elements = 8 Count of elements (updated) = 0
উদাহরণ
আসুন আরেকটি উদাহরণ দেখি -
using System; using System.Collections.Generic; public class Demo { public static void Main(){ Queue<string> queue = new Queue<string>(); queue.Enqueue("A"); queue.Enqueue("B"); queue.Enqueue("C"); queue.Enqueue("D"); queue.Enqueue("E"); Console.WriteLine("Count of elements = "+queue.Count); queue.Clear(); Console.Write("Count of elements (updated) = "+queue.Count); } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেCount of elements = 5 Count of elements (updated) = 0