using System.Collections.Generic; using System.Linq; namespace Extensions { public class LimitedSizeList { public readonly List List; private readonly int _maxSize; public LimitedSizeList(int maxSize) { _maxSize = maxSize; List = new List(maxSize); } public void Add(T item) { List.Add(item); if (List.Count > _maxSize) { List.RemoveAt(0); } } } }