But the question is, I only want my codes to execute only if the listbox doesn't contain the items which are the duplicated of themselves.
For instance, my listbox contains "food", "service", "payment", three items which are initialized with string type. And now if the user selects one of them, then another listbox would copy that value, but then again, if the user selects the same item, that means he or she is selecting the duplicate, and they won't be able to do that. If they are not selecting the same item, then they could do the calculation. By checking the listbox doesn't contain a certain item, then have the codes executed, shall we do this:
for(int i = 0; i < listbox2.Items.Count; i++) if(!(listbox2.Items.contains(listbox1.Items[i])) // codes execute here // statements