Is there some utility to check whether a sequence contains multiple elements instead of using Contains repeatedly?
List<string> containter = new List<string>();
for (int i = 0; i < 10; i++)
{
containter.Add("string #" + i);
}
if (containter.Contains("string #2") && //Is it possible to replace this with one call passing two strings to improve efficiency
containter.Contains("string #6"))
{
//Do Something
}
According to the updated question, I’ve modified my answer:
Still you may use
Any. But in this context it would be nice to useExceptmethod.If every item in
checkListis present in thecontainerthe resulting sequence would contain no elements, soAnyshould returnfalse.