diff --git a/src/Spring/Spring.Core/Util/Generic/CollectionUtils.cs b/src/Spring/Spring.Core/Util/Generic/CollectionUtils.cs index a1d1c368..54b11277 100644 --- a/src/Spring/Spring.Core/Util/Generic/CollectionUtils.cs +++ b/src/Spring/Spring.Core/Util/Generic/CollectionUtils.cs @@ -129,8 +129,31 @@ namespace Spring.Util.Generic } return contains; } - - #endregion + /// + /// Removes all the elements from the target collection that are contained in the source collection. + /// + /// Collection where the elements will be removed. + /// Elements to remove from the target collection. + public static void RemoveAll(ICollection targetCollection, ICollection sourceCollection) + { + if (targetCollection == null) + { + throw new ArgumentNullException("targetCollection", "Collection cannot be null."); + } + + if (sourceCollection == null) + { + throw new ArgumentNullException("sourceCollection", "Collection cannot be null."); + } + foreach (T element in sourceCollection) + { + if (targetCollection.Contains(element)) + { + targetCollection.Remove(element); + } + } + } + #endregion } } #endif \ No newline at end of file