is it possible to convert a List to a Queue element?? Until now i used the code below but adding an extra loop is not necessary if there is a build up method in c#
queue1.Clear();
foreach (int val in list1)
{
     queue1.Enqueue(val);
}
any solution?
Queue<T> has an overload which takes an IEnumerable<T>. Note it will iterate it anyway:
var queue = new Queue<string>(myStringList);
This is what it does internally:
public Queue(IEnumerable<T> collection)
{
    _array = new T[_DefaultCapacity];
    _size = 0;
    _version = 0;
    using(IEnumerator<T> en = collection.GetEnumerator()) 
    {
        while(en.MoveNext()) {
            Enqueue(en.Current);
        }
    }            
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With