Permalink
Browse files

Added ContainsAll extension function.

  • Loading branch information...
1 parent b6c362d commit 64eeb8c61e6ada97b675e42d0175c1628858fdc5 @mwinckler mwinckler committed Jan 20, 2010
Showing with 19 additions and 0 deletions.
  1. +19 −0 libMatt/Linq/Linq.cs
View
@@ -45,6 +45,25 @@ public static class LinqExtensions {
}
return ret;
}
+
+ /// <summary>
+ /// Returns true if <c>source</c> contains all values in <c>values</c>, else returns false.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="source"></param>
+ /// <param name="values"></param>
+ /// <returns></returns>
+ public static bool ContainsAll<T>(this IEnumerable<T> source, IEnumerable<T> values) {
+ if (source == null || values == null)
+ return false;
+
+ bool ret = true;
+ foreach (T item in values) {
+ ret = ret && source.Contains(item);
+ }
+ return ret;
+ }
+
/// <summary>
/// Removes duplicate entries from the IEnumerable based on the delegate you provide.

0 comments on commit 64eeb8c

Please sign in to comment.