c# find difference between two lists of different types code example
Example 1: c# how to check if two lists have same values
var list1 = new List<int> { 1, 2, 3, 1 };
var list2 = new List<int> { 2, 1, 3, 1 };
var list3 = new List<int> { 2, 2, 3, 2 };
bool areTheSame1 = list1.SequenceEqualsIgnoreOrder(list2);
bool areTheSame2 = list1.SequenceEqual(list2);
bool areTheSame3 = list1.SequenceEqual(list3);
Example 2: difference two list c#
var list1 = new List<int> { 1, 2, 3, 4, 5};
var list2 = new List<int> { 3, 4, 5, 6, 7 };
var list3 = list1.Except(list2);
var list4 = list2.Except(list1);
var resultList = list3.Concat(list4).ToList();