private static void Main() { List<Item> knapsackItems = new List<Item>(); knapsackItems.Add(new Item { Name = "beer", Weight = 3, Value = 2, }); knapsackItems.Add(new Item { Name = "vodka", Weight = 8, Value = 12, }); knapsackItems.Add(new Item { Name = "cheese", Weight = 4, Value = 5, }); knapsackItems.Add(new Item { Name = "nuts", Weight = 1, Value = 4, }); knapsackItems.Add(new Item { Name = "ham", Weight = 2, Value = 3, }); knapsackItems.Add(new Item { Name = "whiskey", Weight = 8, Value = 13, }); var bag = new Knapsack(10); bag.Calculate(knapsackItems); bag.All(x => { Console.WriteLine(x); return true; }); Console.WriteLine("Max weight: " + bag.Sum(x => x.Weight)); Console.WriteLine("Max value: " + bag.Sum(x => x.Value)); }