See if entered textbox value exists as part of an array
<p>I am using VS 2012, Windows Forms Project, C#</p>

<p>I have an array of products called <code>products[]</code> that I am getting from an XML file in my project. The user will use a keypad of numbers to enter a product ID (4 digits, read-only textbox) and then I search through the <code>products[]</code> to find the price that matches the ID and give the user back their "change". How can I keep the user from inputting an invalid product ID or after they input the ID and click "purchase" tell them something like "ERROR this ID does not exist." Here is my code for the Purchase button, after the user has put in their "money" and made a 4 digit selection for a product.</p>

<p><code>CoinChange</code> is a class from a DLL given to us for the Bank, it has a method called <code>TotalChange</code> that takes in two arguments to spit back the change, <code>decimal productprice</code> and <code>decimal amountDeposited</code></p>

<pre><code>private void btnPurchase_Click(object sender, EventArgs e)
{
    TextReader reader = null;
    decimal productprice;
    decimal amountDeposited = Convert.ToDecimal(txtDepositAmount.Text);
    int productChoice = Convert.ToInt16(txtChoice.Text);
    XmlSerializer serializer = new XmlSerializer(typeof(Product[]));
    reader = new StreamReader("../../XML/Drinks.xml");
    Product[] products = (Product[])serializer.Deserialize(reader);
    for (int x = 0; x &lt; products.Length; x++)
    {
        if (products[x].productID == productChoice)
        {
            productprice = products[x].price;
            CoinChange CC = Service.TotalChange(productprice, amountDeposited);
            MessageBox.Show("Refund amount:" + "\r\n" + "Nickel: " + CC.Nickel.ToString() + "\r\n" + "Dime: " +
              CC.Dime.ToString() + "\r\n" + "Quarter: " + CC.Quarter.ToString());

            break;
        }
    }
}
</code></pre>

<p>Please don't yell at me if this is not formatted right, I am new to the site and I will fix it just let me know what needs to be fixed. Thank you!</p>
