berkan
berkan

Reputation: 780

C# - If list contains list

I need a condition which is checking for list of string contains all list item of string array.

Example

List<string> list1 = new List<string> { "hello", "it", "is", "an", "example"};

string[] array = { "xa","lo","el","t" };

So, as you can see each items of array exist in list items. It does not matter which item of list contains the which item of array. It should just checking for each item of array is contained by any list's item. In this case I should be true.

Upvotes: 1

Views: 292

Answers (1)

dlxeon
dlxeon

Reputation: 2000

array.All(arrayItem => list1.Any(listItem => listItem.Contains(arrayItem)));

Upvotes: 6

Related Questions