I am working on some homework for class, and decided to add some extra stuff, and wound up confusing myself a bit. I have tried various comparison methods, and none of them seem to work, but I don't understand why.
Basically when an order is added to the system, it creates an instance of the class 'OrderInfo', and adds it to an ArrayList. In my code, I am using a foreach() loop to find the class instance that matches which entry in the ListBox they clicked, but something is wrong.
private void ordersListBox_DoubleClick(object sender, EventArgs e)
{
if (ordersListBox.SelectedItem != null)
{
foreach (OrderInfo i in ordersList)
{
if (String.Compare(i.GetClientName(), ordersListBox.ToString(), true) == 0)
{
MessageBox.Show(i.GetClientName());
break;
}
}
}
}