I am currently looking to make my own collection, which would be just like a regular list, except that it would only hold 10 items. If an item was added when there were alre
Your description of your requirement sounds like a Circular Buffer.
I implemented my own - similar to this implementation on CodePlex except that mine implements IList
.
Some of the other answers suggest using a Queue
- but this isn't quite the same thing, as it only allows FIFO access.
As a general point, it's not recommended to derive from List
- instead derive from Collection
, and implement any additional stuff you need. But for a circular buffer it's probably more appropriate to use a private array rather than deriving from Collection
like the CodePlex implementation.