c# Adding a Remove(int index) method to the .NET Queue class

Alex picture Alex · Feb 10, 2009 · Viewed 44.2k times · Source

I would like to use the generic queue class as described in the .NET framework (3.5) but I will need a Remove(int index) method to remove items from the queue. Can I achieve this functionality with an extension method? Anyone care to point me in the right direction?

Answer

casperOne picture casperOne · Feb 10, 2009

What you want is a List<T> where you always call RemoveAt(0) when you want to get the item from the Queue. Everything else is the same, really (calling Add would add an item to the end of the Queue).