namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var list = new List<DataEntity>(); list = Join(list, new DataEntity { Id = 1, Data = 10 }); list = Join(list, new DataEntity { Id = 2, Data = 20 }); list = Join(list, new DataEntity { Id = 3, Data = 30 }); list = Join(list, new DataEntity { Id = 4, Data = 40 }); list = Join(list, new DataEntity { Id = 5, Data = 50 }); list.ForEach((p) => { Console.WriteLine("ID={0},Data={1}", p.Id, p.Data); }); Console.WriteLine("最大值{0},最小值{1},元素个素{2}", list.Max(p => p.Data), list.Min(p => p.Data), list.Count()); Console.Read(); } static List<DataEntity> Join(List<DataEntity> list, DataEntity entity) { if (list.Sum(p => p.Data) + entity.Data > 100) { while (list.Sum(p => p.Data) + entity.Data > 100) { list.RemoveAt(0); } } list.Add(entity); return list; } } class DataEntity { public int Id{get;set;} public double Data{get;set;} } }