C# beginner here...
I have
int[] numbers = new int[10];
I would like to add 50 numbers to this array. Once the array is full, the first added number will be removed and the new number will be added. I would like to display the last added number on the top of the array. Such as
[5,4,3,2,1...]
not
[1,2,3,4,5,...]
How can I achieve this?
Thanks in advance
This is what I have tried
....
dataArray = new int[10];
....
Queue<int> numbers = new Queue<int>();
....
if (numbers.Count == 10)
{
numbers.Dequeue();
}
numbers.Enqueue(i);
numbers.CopyTo(dataArray, numbers.Count);
I keep getting " Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection" error