0

I used the following 2 linq queries to check if two list are have exactly same contents(the type of list doesn't matter, assume List of string)

bool haveSameContents = list1.All(x=>list2.Any(y=>y==x)) && list2.All(x=>list1.Any(y=>y==x))

//OR

bool haveSameContents = !( list1.Any(x=>list2.All(y=>y!=x)) || list2.Any(x=>list1.All(y=>y!=x)) )
Jajan
  • 887
  • 3
  • 15
  • 28
  • This might help [Quickest way to compare two List<>](http://stackoverflow.com/questions/12795882/quickest-way-to-compare-two-list) – Tone Apr 14 '16 at 11:27
  • No the list are not in same order nor do I know their respective count.. – Jajan Apr 14 '16 at 11:28
  • your linq statement is invalid in case the lists are not unique – fubo Apr 14 '16 at 11:38

0 Answers0