(some meaningless code left out)
if (combo.SelectedItem.ToString() != null && combo.SelectedItem.ToString().ToUpper() == "APPROVED")
{
/*do some stuff*/
}
else if (combo.SelectedItem.ToString() != null && combo.SelectedItem.ToString().ToUpper() == "UNAPPROVED")
{
/*do some stuff*/
}
else if (combo.SelectedItem.ToString() != null && combo.SelectedItem.ToString().ToUpper() == "PAID")
{
VoidPayment(combo.SelectedItem.ToString().ToUpper());
}
else if (combo.SelectedItem.ToString() != null && combo.SelectedItem.ToString().ToUpper() == "ADJUSTED")
{
VoidPayment(combo.SelectedItem.ToString().ToUpper());
}
VoidPayment(string paytype)
{
if (paytype.ToUpper() == "PAID")
else if (paytype.ToUpper() == "ADJUSTED")
}
I am just a novice programmer, but I saw 3 things that seemed strange to me. First, why check for null every time and a ToString().ToUpper() every time? Why not just check it once and set a string that we can check? :confused: Second, in the paid and adjusted if-else sections, why not just pass PAID or ADJUSTED into VoidPayment? In this particular function, the combo box doesn't change. You already know what section you are in due to the if-else logic. (Or we could pass that same string I mentioned a second ago). Third, in the VoidPayment function why are we doing yet another ToUpper when we know we are passing in either a capitalized PAID or ADJUSTED string? VoidPayment is only called from those two spots, and it's not really a function that should be called elsewhere or added anywhere else later. And they wonder why our code is slow....... Cheers, Nathan