Is it possible to store a moving set of values ββin an array without exceeding the set index?
For example, I put together an example of the base console as follows:
static void Main(string[] args) { int[] myvalue; myvalue = new int[10]; for (int i = 0; i < 20; i++) { Console.WriteLine("Array {0} is {1}", i, myvalue[i]); } Console.ReadLine(); }
In the current approach, I get an exception from outside. What I would like to do is limit the array to 10 elements, but as the counter increases, overwrite existing elements with new values. Therefore, I could iterate through 100 times, but the array will only show the last ten values ββ(89-99) at the end of the procedure.
If the array is not the best approach, I would welcome any suggestions on how to store this in memory.
Thank you
source share