using System.Collections.Generic;
public static void Main()
List<InventoryItem> myInventory = new List<InventoryItem>()
new InventoryItem("Milk", 10),
new InventoryItem("Eggs", 20),
new InventoryItem("Apples", 30)
foreach (InventoryItem item in myInventory)
totalItems = totalItems + item.Quantity;
System.Console.WriteLine("I have " + totalItems + " items in my inventory.");
public class InventoryItem
public InventoryItem (string name, int quantity)