public void AddItem(string item, short qty, string unit, decimal price) { if (detail == null) { detail = new[] { new OrderLine() { name = item, qty = qty, unit = unit, price = price } }; } var orderln = detail.Find(o => o.name.Equals(item)); if (orderln != null) { orderln.qty += qty; } else { detail = detail.AddOf(new OrderLine() { name = item, qty = qty, unit = unit, price = price }); } }