Created
July 19, 2013 16:24
-
-
Save dasjestyr/6040462 to your computer and use it in GitHub Desktop.
See if one list is contained within another list. Basically, what this LINQ query does is check every element in the tested list (possessed) to see if one of them matches something in the larger list (required). If every test succeeds, then the result is true;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ListMatcher | |
{ | |
public bool MeetsRequirements(IEnumerable<string> required, IEnumerable<string> possessed) | |
{ | |
//possessed = new List<string> { "a", "b", "d", "g" }; | |
//required = new List<string> { "b", "c" }; | |
var meetsRequirements = required.All(r => possessed.Contains(r)); // false | |
return meetsRequirements; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment