public void changeQuantityInCart(object sender, EventArgs e) { Button button = (Button)sender; int id = Convert.ToInt32(button.Tag.ToString()); String operation = button.Text.ToString(); int i = 0; Boolean found = false; while (!found) { SaleItem item = cart[i]; if (item.getId() == id) { if (operation == "+") { item.incrementQuantity(); } else { item.decrementQuantity(); } found = true; } i++; } generateCart(); }