using System; using System.Linq; public class Test { public static void Main() { var List = new [] { new { tovar_code = 1, tovar_kol = 10, tovar_obyem = 20 }, new { tovar_code = 2, tovar_kol = 20, tovar_obyem = 30 }, new { tovar_code = 3, tovar_kol = 30, tovar_obyem = 60 }, new { tovar_code = 4, tovar_kol = 40, tovar_obyem = 80 }, new { tovar_code = 5, tovar_kol = 50, tovar_obyem = 90 } }.ToList(); var total_quantity = List.Sum(x => x.tovar_kol); var total_volume = List.Sum(x => x.tovar_obyem); Console.WriteLine($"Total quantity: {total_quantity}, total volume: {total_volume}"); var result = List.Aggregate( new { total_quantity = 0, total_volume = 0 }, (sum, curr) => new { total_quantity = sum.total_quantity + curr.tovar_kol, total_volume = sum.total_volume + curr.tovar_obyem }); Console.WriteLine($"Total quantity: {result.total_quantity}, total volume: {result.total_volume}"); int total_quantity_2 = 0; double total_volume_2 = 0; foreach (var item in List) { total_quantity_2 += item.tovar_kol; total_volume_2 += item.tovar_obyem; } Console.WriteLine($"Total quantity: {total_quantity_2}, total volume: {total_volume_2}"); } }