সারির শুরুতে বস্তুটি পেতে, কোডটি নিম্নরূপ -
উদাহরণ
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"); queue.Enqueue("F"); queue.Enqueue("G"); Console.WriteLine("Count of elements = "+queue.Count); Console.WriteLine("Element at the beginning of queue = " + queue.Peek()); } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেCount of elements = 7 Element at the beginning of queue = A
উদাহরণ
আসুন আরেকটি উদাহরণ দেখি -
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"); queue.Enqueue("F"); queue.Enqueue("G"); Console.WriteLine("Count of elements = "+queue.Count); Console.WriteLine("Element at the beginning of queue = " + queue.Peek()); queue.Enqueue("H"); queue.Enqueue("I"); queue.Enqueue("J"); Console.WriteLine("Count of elements = "+queue.Count); Console.WriteLine("Element at the beginning of queue = " + queue.Peek()); } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেCount of elements = 7 Element at the beginning of queue = A Count of elements = 10 Element at the beginning of queue = A