How to copy 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"); 
 
        String[] arr = new String[5]; 

        queue.CopyTo(arr, 0); 

        foreach(Object obj in arr) { 
            Console.WriteLine(obj); 
        } 
    }
}
 
 
 
/*
run:
 
c#
c++
c
java

*/

 



answered Apr 21, 2020 by avibootz

Related questions

1 answer 178 views
2 answers 228 views
228 views asked May 5, 2020 by avibootz
1 answer 193 views
1 answer 149 views
149 views asked Aug 7, 2022 by avibootz
1 answer 160 views
160 views asked Apr 17, 2020 by avibootz
1 answer 77 views
1 answer 147 views
147 views asked Aug 7, 2022 by avibootz
...