public void addProduct(Product product, Product[] productCart) { string reply = product.isProductExists(product.getProductId(), productCart); string[] exists = reply.Split(','); if (exists[0] == "true") { productCart[Int32.Parse(exists[1])].setProductQuantity(productCart[Int32.Parse(exists[1])].getProductQuantity() + 1); } else { for (int i = 0; i < productCart.Length; i++) { if (productCart[i] == null) { productCart[i] = product; break; } } } }