How to cast or convert List of objects to queue of objects

Viewed 29487

How can one convert a list of objects to a queue thereby maintaining the same order?

5 Answers

Add this extension to your toolbox to create a FIFO queue of the specific type.

public static class ListExtensions
{
    public static Queue<T> ToQueue<T>(this List<T> items) => new Queue<T>(items);
}
Related