System.Collections.Queue.CopyTo C# (CSharp) Méthode

CopyTo() public méthode

public CopyTo ( System array, int index ) : void
array System
index int
Résultat void
        public virtual void CopyTo(System.Array array, int index) { }
        public virtual object Dequeue() { throw null; }

Same methods

Queue::CopyTo ( Array array, int index ) : void

Usage Example

Exemple #1
0
        static void Main(string[] args)
        {
            //New Queue of Integers

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(5);
            queue.Enqueue(10);
            queue.Enqueue(15);
            queue.Enqueue(20);

            /*Create new array with
            length equal to Queue's element count*/

            int[] array = new int[queue.Count];

            //Copy the Queue to the Array
            queue.CopyTo(array, 0);

            //Loop through and display int[] in order
            Console.WriteLine("Array: ");

            for (int i=0; i < array.Length; i++)
            {
                Console.WriteLine(array[i]);
            }

            //Loop through int array in reverse order

            Console.WriteLine("Array reverse order: ");
            for (int i = array.Length -1; i >= 0; i--)
            {
                Console.WriteLine(array[i]);

            }
        }
All Usage Examples Of System.Collections.Queue::CopyTo