Search
Close this search box.

IsSubsetOf List extension

I’ve created  IsSubsetOf List extension based on discussion at

http://stackoverflow.com/questions/332973/linq-check-whether-an-array-is-a-subset-of-another

/// <summary>
  /// Determines whether a System.Collections.Generic.List<T> object is a subset of the specified collection.
 /// http://stackoverflow.com/questions/332973/linq-check-whether-an-array-is-a-subset-of-another
 /// </summary>
  /// <param name="list"></param>
  /// <param name="listToFind"></param>
  /// <returns></returns>
  public static bool IsSubsetOf<T>(this List<T> coll1, List<T> coll2)
  {
   bool isSubset = !coll1.Except(coll2).Any();
   return isSubset;
  }
  • Share This Post:
  • Twitter
  • Facebook
  • Technorati   Short Url: http://wblo.gs/boA
This article is part of the GWB Archives. Original Author: Michael Freidgeim’s Blog

Related Posts