using System.Collections.Generic;
using System.Collections.ObjectModel;
public static void Main()
var order = new List<Item>
new Item { Name = "Apple", Price = 0.50m },
new Item { Name = "Banana", Price = 0.75m },
new Item { Name = "Vitamins", Price = 5.50m }
Console.WriteLine("Subtotal: " + order.Sum(item => item.Price));
Console.WriteLine("========================================");
Console.WriteLine("Let the customer preview their order");
var customerPreview = new ReadOnlyCollection<Item>(order);
Console.WriteLine("Customer changes the price of the last item");
customerPreview.Last().Price = 0.25m;
Console.WriteLine("========================================");
Console.WriteLine("Subtotal: " + order.Sum(item => item.Price));
public string Name { get; set; }
public decimal Price { get; set; }