1

I have two sting lists

List<string> list1=new List(){"1","2","3"};
List<string> list2=new List(){"1","2"};

What will be the easiest way to check if list1 contains the values in list2.

udaya726
  • 1,010
  • 6
  • 21
  • 41

2 Answers2

5

How about

list1.Except(list2).Any();
Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208
  • That doesn't check if list1 contains the values in list2, it check is list2 doesn't contain the values in list 1. – Guffa Jun 16 '14 at 08:50
0

Try using [listName].Except(SecondListName).Any();

This should work.

Mohammad Alqurm
  • 577
  • 6
  • 23