I need to add items to an arraylist until the count gets to, for example, 100 and then read them on a first in first out basis
Printable View
I need to add items to an arraylist until the count gets to, for example, 100 and then read them on a first in first out basis
I see that you created this thread by misstake, but just for further reference, you should use a System.Collections.Generic.Queue(Of T).
A queue would be the right way to go about it, but you could also use a List (of T), and just add to the end. You would then read from first to last. A queue will do more than that, because it will remove the first item each time such that the queue count will shrink each time you read it. That may be less desirable if you have any reason to maintain the list after the reading.
I have posted examples of queues here.