I do understand how Stack()
and Stack
works, but I really can\'t see any scenarios where an array, List
or IEnumer
Stack
's functionality really seems like a subset of List
(with a few renamed methods), so I agree it doesn't seem like the most useful collection by itself. When used internally in an algorithm, List
can easily substitute for it, even if that may be slightly less idiomatic.
Enforcing stack behavior is only necessary if it is exposed publicly. But it that case it's usually a better idea to expose some kind of wrapper over the internal collection, so it doesn't really seem very useful for that either.I'd certainly see use for a IStack
interface, but not so much for a plain collection class Stack
.
My conclusion is that I wouldn't have included a Stack
class in the framework, just a IStack
interface. The BCL collections generally don't look very well thought out to me.
ConcurrentStack
on the other hand seems much more useful.