title: Shifting array data structure C#
body: <p>I was curious to know if there is an efficient way to store data into a container that has a maximum amount of values and when that value is reached it start removing the oldest values in order to add new ones. And all this in an ordered fashion (meaning that new data should come after the last new data).</p>
  
  <p>I know I could achieve this using a queue </p>
  
  <pre><code>    q.Enqueue(1);   
      q.Enqueue(2);   
      q.Enqueue(3);  // 1 2 3
  
      q.Dequeue(); // 2 3 
      q.Enqueue(4); // 2 3 4   
  </code></pre>
  
  <p>but in order to iterate through the data afterwards requires to transform the queue in an array, which I'm not sure how efficient it is.</p>
  
  <p>Maybe it's better to have an array with a fixed size and have an index that shifts to the start when the array is full and using some modulo magic iterate always backwards to query the data from most recent to less recent. This would be less readable but working and more efficient I guess.</p>
  
  <p>So my question would be, is there a better more readable and efficient way?
  And also, what is the efficiency of using ToArray() when using other data structures (e.g. List, Queue, Stack..). When should this be avoided? </p>