You cannot delete items in your theFinalList list while you iterate over theFinalList in a foreach . In this case, you may receive a System.InvalidOperationException with the message "The collection has been changed, the enumeration operation may not be performed."
you need to do something like this:
List<string> removals = new List<string>(); foreach (string s in theFinalList) {
user195488
source share