I have a list of items in my list and some of these items are duplicates that were added, at the customer's request because she wanted a message after the add to be displayed to the customer that they could not add a duplicate item to this list. The user then clicks on the duplicate item and we need to remove that duplicate item and not all the original item that match that item number. All I've been seeing when googling is a way to remove ALL duplicate items and not just the record that was added that is considered a duplicate.
My code is below and I need to determine the last duplicate item and then delete that one item by passing in that last duplicate item to my deleteItem() below and keep the original item it duplicated. Any help would be greatly appreciated.
I thought I had my problem resolved given an answer I found in the archives of this forum. However, I am still having a problem. I was able to remove the duplicate records from the list using the HashSet since HashSet does not allow duplicates.
However, my question is since I'm setting aSet to a new HashSet using items it would seem that aSet will always find records that will reside in items or am I thinking incorrectly here?
If the object duplicateItems is NOT populated then I just want to delete the items sent to this method but duplicateItems is constantly being populated and I just want it populated if duplicates are found in items.