What I need is a collection where i can specify the max number of elements. If i try to insert an element and the collection is full. The first element in the collection is removed, so that it does not overflow.
Is there such an object in .net or do i have to make it myself?
You can extend Queue class in order to do it.
For example:
(this example is very naive. It is not thread safe, it doesn’t check the maxItems is at least 1. It is based on Queue so you’re safe to know you dequeued the first item added to it)