private void CalculateTotal() { totalCost = 0; foreach (Product product in items.Values) { // Sum of (quantity * price) for all products. totalCost += (product.Price * product.Quantity); } }