Queue<T>
and Stack<T>
To conclude our journey through the generic collection types, we meet again with the queue and stack collections in a generic shape. Because their use is completely analogous to the nongeneric counterparts, we’ll just go for a translation of the original example, now with stronger type checking at compile time and making ugly casts go away:
And for a stack
Get C# 4.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.