সারিকে অ্যারেতে রূপান্তর করতে, কোডটি নিম্নরূপ -
উদাহরণ
using System; using System.Collections.Generic; public class Demo { public static void Main(){ Queue<int> queue = new Queue<int>(); queue.Enqueue(100); queue.Enqueue(200); queue.Enqueue(300); queue.Enqueue(400); queue.Enqueue(500); queue.Enqueue(600); queue.Enqueue(700); queue.Enqueue(800); queue.Enqueue(900); queue.Enqueue(1000); Console.WriteLine("Queue..."); foreach(int i in queue){ Console.WriteLine(i); } int[] intArr = queue.ToArray(); Console.WriteLine("Convert Queue to Array..."); foreach(int i in intArr){ Console.WriteLine(i); } } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেQueue... 100 200 300 400 500 600 700 800 900 1000 Convert Queue to Array... 100 200 300 400 500 600 700 800 900 1000
উদাহরণ
এখন আরেকটি উদাহরণ দেখা যাক -
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"); Console.WriteLine("Array..."); foreach(string i in queue){ Console.WriteLine(i); } string[] strArr = queue.ToArray(); Console.WriteLine("Convert Queue to Array..."); foreach(string i in strArr){ Console.WriteLine(i); } } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেArray... A B C D E F Convert Queue to Array... A B C D E F