Reset list values every given time

I’ll try to be quick and clear. I have the Firefly “Frequency Spectrum” tool outputting real-time noise data in multiple frequencies. I want to store the first 50 values of the first 30 frequencies in a tree which would represent the different noises that sounded over a period of time.
It would be something like a recorder that stops recording once it reaches 50 values for the 30 branches. I’ve tried to code it in C# (I have zero knowledge about coding) using the recorder for getting the data but I’m just able to make the same as the Prune command does.
Can anyone help me?

private void RunScript(DataTree<double> listsbox, int readingMax, ref object A)
  if (listsbox.DataCount > readingMax)
    // erase the list}
  A = listsbox;
  private void RunScript(double Data, int Limit, ref object A)

    if (_data.Count > Limit)
      _data.RemoveRange(0, _data.Count - Limit);

    A = _data;

  // <Custom additional code> 
  private readonly List<double> _data = new List<double>();
  // </Custom additional code> 

Don’t put in negative limits. (19.1 KB)

Thanks a lot for the quick answer, David!
Keep up the great work.