Convert Queue to Array, starting at the specified array index in CSharp

Description

The following code shows how to convert Queue to Array, starting at the specified array index.

Example


/*  ww w  .  j  a va  2 s.  c  o m*/
using System;
using System.Collections;
using System.Collections.Generic;

class Sample
{
    public static void Main()
    {
        Queue<string> words = new Queue<string>();

        words.Enqueue("A");
        words.Enqueue("B");
        words.Enqueue("C");
        words.Enqueue("D");
        words.Enqueue("E");
        words.Enqueue("F");


        string[] existing = new string[1000];
        words.CopyTo(existing,0);
        
        foreach(string s in existing){
           Console.WriteLine(s);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary