Is there an easy way, either through LINQ or Generics, to find out if elements in one List are all available in another List.
I’m currently using Intersect to check this.
For e.g.
List<string> list1; //{ 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }
List<string> list2; //{ 1, 3, 9 }
list1.Contains(list2) == true
Thanks in advance
The
Intersectmethod will give you all the elements that are in both lists.E.g.
or if you just want to know if there are any shared elements between the two