How to convert queue to array in C#

1 Answer

0 votes
using System;
using System.Collections;

class Program
{
    static void Main() {
        Queue queue = new Queue(); 

        queue.Enqueue("c#"); 
        queue.Enqueue("c++"); 
        queue.Enqueue("c"); 
        queue.Enqueue("java"); 

        Object[] arr = queue.ToArray(); 
  
        foreach(Object obj in arr) { 
            Console.WriteLine(obj); 
        } 
    }
}



/*
run:

c#
c++
c
java

*/

 



answered Apr 17, 2020 by avibootz

Related questions

1 answer 154 views
154 views asked Aug 7, 2022 by avibootz
1 answer 157 views
157 views asked Aug 7, 2022 by avibootz
1 answer 159 views
159 views asked Apr 21, 2020 by avibootz
1 answer 190 views
1 answer 82 views
1 answer 130 views
130 views asked Aug 3, 2022 by avibootz
2 answers 238 views
238 views asked May 5, 2020 by avibootz
...