I'm trying to remove duplicates of one arraylist filled with the objects "DataPerLabel".
DataPerLabel contains the following methods: getLabelname(), getLabelAdress() and getDataType().
Some background information:
The values labelname, labelAdress and dataType can be set as 1 object in an arraylist named allData by a submit button. When submit is pressed for the 2nd time i want to delete that object of the arraylist.
Picture: 
Some of the code i've tried:
if (submitButtonClicked == true) {
if (MessageBox.Show("This is item is already set. Do you want to delete?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
foreach(DataPerLabel item in allData) {
if (item.getDataType().Equals(dataType) && item.getLabelAdress().Equals(adress) && item.getLabelName().Equals(label)) {
allData.Remove(item);
} else {
}
}
} else {
//no
}
}
With this code i'm getting the following error: An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll.
Additional error information: The collection has been changed.